Saturday, 21 December 2013

Importing data from an XML file in ax 2012

class ReadXmlFile
{
}
public static void main(Args _args)
{
XmlDocument doc;
XmlNodeList data;
XmlElement nodeTable;
XmlElement nodeAccount;
XmlElement nodeName;
#define.filename(@'C:\Temp\accounts.xml')
doc = XmlDocument::newFile(#filename);
data = doc.selectNodes('//'+tableStr(MainAccount));
nodeTable = data.nextNode();
while (nodeTable)
{
nodeAccount = nodeTable.selectSingleNode(
fieldStr(MainAccount, MainAccountId));
nodeName = nodeTable.selectSingleNode(
fieldStr(MainAccount, Name));
info(strFmt(
"%1 - %2",
nodeAccount.text(),
nodeName.text()));
nodeTable = data.nextNode();
}

}

3 comments:

  1. Can we post sales order.the data is in xml file..plz guide me

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi Fiazuddin,

      Refer these links,
      https://community.dynamics.com/ax/f/33/t/157131
      https://erpdax.wordpress.com/2015/03/19/read-import-data-from-xml/

      Delete