Importing an XML File with repeating, interspersed siblings.

I am importing an XML file from Amazon that reports my client’s sales for two weeks.

The file gives the complete information on all orders, refunds and coupons used.

My XMLPort is set up to read in all orders, then all refunds and then all coupons.

However, the file contains the coupons intermingled with the refunds.

Example below. XMLPort dies when is sees a refund after a coupon.

Order Data
Order Data
Refund data
Coupon data
Refund data

Any way to handle this?

XMLport is a simple and straightforward object, it requires strict sequence of elements in the XML. Data structure like the one in your example would have an xs:choice element in the schema, and it is not supported in XMLports. Looks like you’ll have to import the file from AL (or C/AL) code with either .Net components, or a codeunit “XML DOM Management” - depending on the NAV version.

Thanks for the data. That’s too bad. My XMLPort was a thing of beauty except for the one small point of it not working.

Yes, XMLports are very convenient for their specific tasks, but this simplcity imposes certain limitations.

On the other hand, just had another idea - it should be possible to import this kind of structure with data exchange framework. It works not from the XML schema, but vice versa - traverses all document nodes and looks for a suitable field mapping definition. Which means, it will not fail on varying nodes. I think Data Exchange Definition is a tool to solve this.