<PurchaseOrderLineMessage> <PurchaseOrderNo>PO0000001</PurchaseOrderNo> <PurchaseOrderLineNo>20000</PurchaseOrderLineNo> et cetera, et cetera... </PurchaseOrderLineMessage>
XMLDomDoc.loadXML(XMLMessage); FOR i := 0 TO XMLDomDoc.childNodes.item(0).childNodes.length-1 DO BEGIN CLEAR(XMLNode); XMLNode := XMLDomDoc.childNodes.item(0).childNodes.item(i); CASE XMLNode.nodeName OF 'PurchaseOrderNo' : PurchOrderNo:=LTMNode.text; 'PurchaseOrderLineNo' : EVALUATE(PurchOrderLineNo,XMLNode.text); et cetera, et cetera... END; END;
Comments
6224 XML DOM Management
6225 XML Document Encode
6226 XML Document Decode
They give a good picture on how you should use the XML DOM object.
Regards,
...
Everybody on-line.
...
Looking good!
RIS Plus, LLC
RIS Plus, LLC
Let's assume we have a <table> <field> <field/> <field> </field></table>hierarchy. We write code to read that. Then later on turns out that we need in fact multiple tables and wrap a <tables> </tables> node around them. Then the selectSingleNode approach needs to be completely rewritten, while my rude and ugly approach needs only another FOR loop wrapped around it.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
SelectSingleNode selects a single node into a node object, including all subnodes of that node. It is not a free text search, it is an MSDOM object that can hold more than 1024 characters for instance, because it's not a text variable.
In the XML codeunits you'll find examples of loops, once you know how it's done it's not that hard.
Ahmed, I disagree with you about the use of XMLPorts vs. MSDOM. Using the MSDOM is more code, but does not have the limitations of XMLPorts. You just have more control. The trick is to know when to use which one, and that's not easy to do
RIS Plus, LLC