Read \ Import data from XML

Below code snippet is to Read \ Import data from XML File to AX

class ImportDataFromXmlFile

public static void main(Args _args)
    XmlDocument doc;
    XmlNodeList data;
    XmlElement nodeTable;
    XmlElement nodeAccount;
    XmlElement nodeName;
    Table6 tab;
    doc = XmlDocument::newFile(#filename);
    data = doc.selectNodes('//'+tableStr(Table6));
    nodeTable = data.nextNode();

    while (nodeTable)
            nodeAccount = nodeTable.selectSingleNode(fieldStr(Table6, Id));
            nodeName = nodeTable.selectSingleNode(fieldStr(Table6, Name));
            tab.Id = nodeAccount.text();
            tab.Name = nodeName.text();
            info(strFmt("%1 - %2",nodeAccount.text(),nodeName.text()));

            nodeTable = data.nextNode();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s