Reading XML using X++

In X++ there are some tools available to read an incoming XML file and do some work with it.  XMLNode, XMLNodeList, and XMLElement are the main ones.  An example below shows using a for loop to move through tags under a root.  You can then nest for loops in order to go through more complex XML files.

nodeRoot = _xmlDoc.getNamedElement('ROOT');
nodeList = nodeRoot.childNodes();
        for (i=0; i < nodeList.length(); i++)
        {
            node = nodeList.item(i);
            switch(node.name())
            {
                case 'NODE1':
                      //Insert your code here
                      break;
                case 'NODE2':
                      //Insert your code here
                      break;
             }
        }

Comments

Popular posts from this blog

Posting Purchase Order Invoices via X++

Using X++ to get a list of files in a directory

Split a production order with X++