Moving NAV Web Service Code from COM to .NET

I have a NAV Web Service running on NAV2009R2 using Automation Controls to read the XMLs received.

This service is now going to be transferred to NAV2015 and therefore the COM variables must be changed to .NET variables.

I have managed to do this, but I have a problem reading through a loop of nodes in the XML file.

The file looks like this:


Using COM variables we loop through the orderlines using code like this:

But the COM Methods “NextNode” and “Reset” are not supported for the .NET variabel System.Xml.XmlNodeList

Can anyone please provide an example of how to read all the fields on the 3 different sales lines in the XML document using .NET (System.Xml) in C/AL?


I have tried using GetElementsByTagName in the code here, but then I only get the first Node (the ItemNo) and not the Quantity or any other following Nodes (there could be and other Nodes added which are not mandatory fields, so each must be read in total before moving on to the next ):


use nextsibling instead.


NextSibling is a property of an XmlNode though not XmlNodeList.

If Erik must use XmlNodeList, there’s the possibility to do myXmlNodeList.GetEnumerator.MoveNext;

Thanks for your suggestions. I have tried to work with both methods, but ended up using the code below. It isn’t beautiful, but it works, and this way I am sure that the “pointer” which reads the data in the product section is always in the right position (by moving each product section to a temporary separate XmlDoc variable):

XMLNodeList1 := XmlDoc.GetElementsByTagName(‘product’);
FOR i:=0 TO XMLNodeList1.Count-1 DO BEGIN
XMLNodeElem1 := XMLNodeList1.Item(i);
XmlDoc2 := XmlDoc2.XmlDocument;
XMLNodeElem1.InnerXml := ‘’ + XMLNodeElem1.InnerXml + ‘’;
inputId := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/ItemNo’));
inputQuantity := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/qty’));
inputVariant := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/variant’))