Interview Questions

Wednesday, May 14, 2014

Copy data from Ax to Xml File in ax 2012

static void JobAxToXML(Args _args)
{
    XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeAccount;
XmlElement nodeName;
CustTable CustTable;
#define.filename('D:\\Somendra\\accounts.xml')
;
doc = XmlDocument::newBlank();
nodeXml = doc.createElement('xml');
    doc.appendChild(nodeXml);
while select CustTable
{
nodeTable = doc.createElement(tablestr(CustTable));
nodeTable.setAttribute(
fieldstr(CustTable, RecId),
int642str(CustTable.RecId));
nodeXml.appendChild(nodeTable);
nodeAccount = doc.createElement(
fieldstr(CustTable, AccountNum));
nodeAccount.appendChild(
doc.createTextNode(CustTable.AccountNum));
nodeTable.appendChild(nodeAccount);
nodeName = doc.createElement(
fieldstr(CustTable,BankAccount));
nodeName.appendChild(
doc.createTextNode(CustTable.BankAccount));
nodeTable.appendChild(nodeName);
}
doc.save(#filename);
}

No comments:

Post a Comment