XMLPort - Order of elements
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
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?
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.
0
Answers
-
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
Comments0 -
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.0 -
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.0 -
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.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
