How to Write Data in XML File
Today I will demonstrate you that how to write data in XML file in AX. static void WriteXml(Args _args) { XmlDocument xmlDoc; XmlElement xmlRoot; XmlElement xmlField; XmlElement xmlRecord; XMLWriter xmlWriter; CarTable carTable; DictTable dTable = new DictTable(tablenum(CarTable)); DictField dField; int i, fieldId; str value; #CarsXmlTags ; xmlDoc = XmlDocument::newBlank(); xmlRoot = xmlDoc.createElement(#CarRootNode); while select carTable { xmlRecord = xmlDoc.createElement(#CarRecords); for (i=1; i<=dTable.fieldCnt(); i++) { fieldId = dTable.fieldCnt2Id(i); dField = dTable.fieldObject(fieldId); if (dField.isSystem()) continue; xmlField = xmlDoc.createElement(dField.name()); switch (dField.baseType()) { case Types::Int64 : value = int642str(carTable.(fieldId)); break; case Types::Integer : value = int2str(carTable.(fieldId)); break; default : value = carTable.(fieldId); break; } xmlField.innerText(value); xmlRecord.appendChild(xmlField); } xmlRoot.appe...