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;
    #define.filename(@'C:\Temp\TestXML.xml')
    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();
            tab.insert();
            
            info(strFmt("%1 - %2",nodeAccount.text(),nodeName.text()));

            nodeTable = data.nextNode();
        }
}
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s