09 July 2015

Read XML file in AX 2009 / 2012


static void ReadXml_New(Args _args)
{
XmlDocument xmlDoc;
#define.node("Data\Invoice")
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord;
XmlNodeList xmlRecordList;
XmlNodeList xmlFieldList;
XMLElement xmlEl;
XMLNode xmlNode;
//CustTable carTable;
//DictTable dTable = new DictTable(tablenum(CarTable));
int i, j, fieldId;
//#CarsXmlTags
;
// Create an XmlDocument object to hold the
// contents of the xml-file
xmlDoc = new XmlDocument();
// Load the content of the xml-file
// into the XmlDocument object
xmlDoc.load(@"c:\Users\abc\Desktop\myxmlInvoice.xml"); // @'C:\Users\abc\Desktop\Invoice.xml'

// permission.assert();
//doc = XMLDocument::newXml(xmlDoc); // this line is to take xml parse data as a parameter and creating new xml file in the code.

// Get the root node
xmlRoot = xmlDoc.getNamedElement("Data");

// Get all child nodes (records)
xmlRecordList = xmlRoot.childNodes();

// Loop through the list of records
for (i=0; i {
//carTable.clear();
// Get the current record from the
// record list
xmlNode = xmlRecordList.nextNode();
xmlRecord = xmlRecordList.item(i);
// Get all child nodes (fields)
xmlFieldList = xmlRecord.childNodes();
// Loop through the list of fields
for (j=0; j {
// Get the current field from the
// field list
xmlField = xmlFieldList.item(j);
// Set the matching field in the carTable
// to be equal to the inner text
// (the text between the tag and end tag).
info(xmlField.name());
//carTable.(dTable.fieldName2Id(xmlField.name())) =
info(xmlField.innerText());
}
// Insert the record into the carTable
//carTable.insert();
}
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...