XMLPort - starter help

jversusj
Member Posts: 489
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:
other times i may receive a file like this:
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.
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...
0
Comments
-
0
-
As far as optional elements, there is a property called MinOccurs, Set it to zero.
As far as repeated elements, the way you are doing it is fine.0 -
Savatage wrote:
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!kind of fell into this...0 -
bottom line, do i have to have every potential element listed in the XML port, or will NAV just ignore whatever i do not include?
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!kind of fell into this...0 -
jversusj wrote:bottom line, do i have to have every potential element listed in the XML port, or will NAV just ignore whatever i do not include?jversusj wrote:Most of the data contained in the file i am receiving is extraneous and is not needed in NAV.0
-
DenSter wrote:Yes. You can use the MinOccurs property as Rashed suggested in case of optional elements
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:<extrinsic name="TAXABLE">N</extrinsic> <extrinsic name="account code">1469200</extrinsic> //this is the buyers internal commodity code for the good which I have no use for <extrinsic name="LINEORIGIN">Catalog</extrinsic>
these are optional fields that can be added or omitted by the buyer. how would i set up the xmlport to handle this?kind of fell into this...0 -
Ah that is an attribute that belongs to an element. Off the top of my head, you create a line in the XMLPort for an element called 'extrinsic', and indented underneath it you create lines for all possible attributes, each one with its proper minoccurs and maxoccurs property. I don't exactly know how it would behave, you'll have to play around with it. I would think you can put the attribute values into global variables that you can then evaluate and process in a dataitem trigger of the extrinsic element.
Check out XMLPort 8610 for an example with an attribute.0 -
thank you!
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...kind of fell into this...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions