Traverse XML file in X++ AX

Hi,

Traverse XML file in X++ AX

static void XMLJob(Args _args)
{
   #define.node('TrvPBSMaindataServiceCreateRequest')
   XmlDocument xmlDocument;
   XmlNode     xmlInformationNode;
   XmlNodeList xmlInformationsNodeList;
   XmlNodeList xmlChildNodeList;
   int         i;
   int         j, k;
   str fileName                = 'C:\\CreditCardImport.xml';
   xmlDocument             = xmlDocument::newFile(fileName);
   info(xmlDocument.documentElement().nodeName());
   xmlInformationsNodeList = xmlDocument.documentElement().childNodes();
   setPrefix("@SYS98689");
   for ( i = 0; i < xmlInformationsNodeList.length(); i++)
   {
       xmlChildNodeList = xmlInformationsNodeList.item(i).childNodes();
       for (j = 0; j < xmlChildNodeList.length() ; j++)
       {
           xmlChildNodeList = xmlChildNodeList.item(j).childNodes();
           for (k = 0; k < xmlChildNodeList.length() ; k++)
           {
               xmlInformationNode = xmlChildNodeList.item(k);
               info(strFmt('%1 -> %2', xmlInformationNode.nodeName(), xmlInformationNode.innerText()));
           }
       }      
   }
}

Reference
Reference

Comments

Post a Comment