Wednesday, January 28, 2015

Read XML file in ax 2012 R2 X++

// Read XML file in ax 2012 R2  

static void Readxmldoc(Args _args)
{
    XmlDocument doc;
    str 10000   note;   
    #define.filename(@'C:\sanPayslip.xml')
   
    doc = XmlDocument::newFile(#filename);   
    note = doc.toString();   
    info(note);
}

Source:

XmlDocument doc;
    XmlNodeList data;
    XmlElement nodeTable;
    XmlElement nodeAccount;
    XmlElement nodeName;
    XmlElement nodeRecId;
    XMLTestTable    xmlTable;
    #define.filename(@'C:\Temp\accounts.xml')
    doc = XmlDocument::newFile(#filename);
    data = doc.selectNodes('//'+tableStr(CustTable));
    nodeTable = data.nextNode();
    delete_from xmlTable;
    while (nodeTable)
    {
        nodeAccount = nodeTable.selectSingleNode(fieldStr(CustTable, AccountNum));
        xmlTable.AccountNum = nodeAccount.text();
        xmlTable.Name = CustTable::find(nodeAccount.text()).name();
        //nodeRecId = nodeTable.selectSingleNode(fieldStr(CustTable, RecId));
        //xmlTable.CustRecId = str2int64(nodeRecId.text());
        info(strFmt("%1 - %2",nodeAccount.text(),nodeRecId.text()));
        //xmlTable.insert();
        nodeTable = data.nextNode();
    }

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...