i have never worked with XML files before. The system i am working in has 3.7 objects sitting on a 5.0 executable. I was recently tasked with getting a cXML document being transmitted by our customer to import into NAV. We bought the XMLPort granule for our license and I read the XMLPort section of the application designers guide.
I have some questions that i could not find answers for already on this forum.
I get the impression that XMLPorts only work when you are processing XML files that always follow the same format, and that you must explicitly list each and every element and attribute that are to be encountered. Is this correct? If so, how are people handling XML documents that have dynamic formats?
Perhaps it is better if i give a generalized and simplified example.
sometimes i can get an order where the ship-to elements look like this:
<xml>
<customer>
<shipto>
<deliverto>the store</deliverto>
<deliverto>home furnishings department</deliverto>
<deliverto>Jan Smith</deliverto>
<street>123 Street</street>
<city>Any Town</city>
</shipto>
</customer>
</xml>
other times i may receive a file like this:
<xml>
<customer>
<shipto>
<deliverto>the store</deliverto>
<street>ABC street</street>
<city>Any Town</city>
</shipto>
</customer>
</xml>
the amount of info included is up to the customer creating the PO on their end. they can add optional values if they want to. they have nothing forcing them to use a certain format.
what would i do in my XMLPort to make this work?
Further, they keep using an element called "Extrinsic" over and over again, and it can pop up for an address or not at all, or pop up on an item or not at all. Is it unusual that the cXML file i receive makes use of the same element names over and over again and different levels of indentation? for example, Credential shows up 5 times, and each Credential has a domain attribute that goes with it. My NAV doesn't need any of this data, but i have to tell it is there, correct? so i have a ton of text variables with ugly names like Credential1 thru Credential5, for example.
kind of fell into this...
Comments
Xml Import Sample
viewtopic.php?f=7&t=2266
Xml Export
viewtopic.php?f=7&t=1775
http://www.BiloBeauty.com
http://www.autismspeaks.org
As far as repeated elements, the way you are doing it is fine.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
for this minoccurs=0 angle, how do i know the element should even exist, if the customer can just add stuff whereever they want? do i add 10 deliverto elements and set the minoccurs to 0, just to be sure i can handle whatever they send?
i'm so confused!
Most of the data contained in the file i am receiving is extraneous and is not needed in NAV.
any help or sugguestions are greatly appreciated!
RIS Plus, LLC
thanks!
yikes! how would i handle an optional element called Extrinsic that has any number of attributes and values? would i set the min occurs to zero for extrinsic and for its attribute? how would i read the differing attributes and know where to put them in NAV?
example:
these are optional fields that can be added or omitted by the buyer. how would i set up the xmlport to handle this?
Check out XMLPort 8610 for an example with an attribute.
RIS Plus, LLC
i have been trying to get a complete list of the possible attributes from the buyer but that has not been forthcoming. I am happy to know that i have not been mistaken in requesting this information. if i can get a list from them, i should be in much better shape to handle this.
thanks again to everyone.
i won't mark this solved just yet...