Navision XMLDOM Help.

I have an issue trying to integrate Navision with a webservice.

I can read in the XML fine via soap and can load this into an XMLDom object. My problem is caused by the format of the data.

The data in the XML does not map onto any navision fields and therefore I need to handle each tag individually to decide what I need to do with the information [:’(]

The xml returned will be in this format:




The list of fields and name of fields will vary from record to record and new ones will be added over time that will need to be handled and this is oiut of mu control. (I will be looking up the field/tag name in a separate table to handle this!).

So what I need to be able to do is take each ‘record’ tab in turn and then read the list of field/tag names and values in order whatever they may be.

I have done something similar using ‘getelementsbytagname’ in C# but can’t seem to get this working in Navision.

Any ideas or pointers in the right direction would be hugely appreciated. I’m sure there is an easy way of doing this but I think my brain has fried in the heat [;)]

What version are you using? 4.0 has xml ports that you can use. It has property called MinOccurs that you can set to zero for all the elements.
If not then I would create a table where you can define the field tags to navision fieldNo.
While decoding the xml document you’ll loop through the records and search for them in the xml document. As new xml tags are added, you only add them to the table. You have to use fieldreference and record reference to be able to do this.

Hi Gary,

I had the same problem.

I had a generic solution whereby a response xml could contain 5 or even 10 tags.

So I populated an array of 2x999

The first part of the array contained the field descriptor (tagname), and the second the actual data.

That way I could just run a loop on the Array and find what I needed. I knew the tagname so could do a

CASE XmlArray[1,X] Of

Not sure if that helps you. Let us know!

Kinda not the point of an XML file, but when the file changes what can you do?


I would try to generate a new table with mappings for record identifiers and field tags.

Once you receive the XML file , you just search for the identifier in your table and know what table it relates to.

Then you loop through all fields in that table and try a GetElementByName (I cannot exactly remember if that was the name)

Then you should be able to find all fields you are interested in.
To extend your functionality you just need to add additional TAGs to your definition table.

So in fact: build your own XMLPort !!!

Or just use that one if you are running 4.0.

Thanks for the input guys.

I can’t use easily use XML ports as this would need resigning each time a field was added - and I think this is going to happen a lot!

I was already leaning in the direction of Thomas’ suggestion and will go that route. Now all I have to remember is all the quirky things about using XMLDom in Navision so I can code this. [;)]