XMLPort - Order of elements

ahed4
ahed4 Member Posts: 21
Hi there,

I was trying to create an XMLPort for the first time these days. Obviously ... troubles. The one that upset me the most was the following:

Apparently the order in which I create the elements in the XMLPort absolutely has to match the one in the XML file itselft.
Example:
I have an XML file that is structured like
<header>
 <lines>
  ..
 </lines>
 <comments>
  ...
 </comments>
 </header>

Now if I create my XMLPort to match this, everything works fine.

But then: suppose I receive a second XML file, that is structured differently, say the <comments> element comes first and the <lines> element comes second. It should not change anything. And content-wise its totally the same, ain't it? But my XMLPort does not work in that case. It says he expects <lines> to come first. And yes, I tried to mess with the properties minOccurrs ecc.

Anyone else experienced this?
The freaks come out at night.

Answers

  • ara3n
    ara3n Member Posts: 9,258
    you can add two Comment section in your dataport and set both of them to minOccurance to zero.


    So your dataport will look like this.


    Header.
    Comments
    Lines
    Comments
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ahed4
    ahed4 Member Posts: 21
    Well true, I could do that.
    But in reality my XMLPort has about 10 of these elements. And I can't possibly create an XMLPort with all combinations. There has to be a way to solve this? The fact that I do not create the XML files myself, but they are created from an external source (vendor ecc.), leaves me in the position where I have to expect every kind of strange files. But as long as they conform to XML-standard I need to be able to read them.
    The freaks come out at night.
  • ara3n
    ara3n Member Posts: 9,258
    Use MSxmlDOM automation and read the xml file first. restructure it to the way your xmlport expect and then process it.
    This is what I've done in the past.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ahed4
    ahed4 Member Posts: 21
    Oh nice idea, thanks. But well, the effective database transactions I have to do are pretty straight forward, so I may as well use MSXML for the entire import and let the XMLPorts be. Will try that.
    Still ... I am just stunned that XMLPorts have this kind of limitation ...
    Thanks though!
    The freaks come out at night.