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?
EDIT:
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 ):
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’);
CLEAR(inputId);CLEAR(inputQuantity);CLEAR(inputVariant);
FOR i:=0 TO XMLNodeList1.Count-1 DO BEGIN
XMLNodeElem1 := XMLNodeList1.Item(i);
CLEAR(XmlDoc2);
XmlDoc2 := XmlDoc2.XmlDocument;
XmlDoc2.RemoveAll;
XMLNodeElem1.InnerXml := ‘’ + XMLNodeElem1.InnerXml + ‘’;
XmlDoc2.LoadXml(XMLNodeElem1.InnerXml);
inputId := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/ItemNo’));
inputQuantity := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/qty’));
inputVariant := ConvertEscapeToText(GetSingleNodeValue(XmlDoc2,‘xml/variant’))