Hello everyone! I need to export some data from the AX in Xml file. I used the XMLElement and XMLNode classes, but the lines must be terminated with “0d0a” and I do not know how to do. Can anyone help me? Thanks.
Wanderson
Hello everyone! I need to export some data from the AX in Xml file. I used the XMLElement and XMLNode classes, but the lines must be terminated with “0d0a” and I do not know how to do. Can anyone help me? Thanks.
Wanderson
Hello Wanderson,
Use following job for XML export, Please change your table and Fields
static void XMLExport(Args _args)
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeAccount;
XmlElement nodeName;
XmlElement nodeItemName;
XmlElement nodeModelGroup;
XmlElement nodeDimGroup;
InventTable inventTable;
#define.filename(‘C:\Users\varun.garg\Desktop\test.xml’)
;
doc = XmlDocument::newBlank();
nodeXml = doc.createElement(‘xml’);
doc.appendChild(nodeXml);
while select inventTable
{
nodeTable = doc.createElement(tablestr(InventTable));
nodeTable.setAttribute(
fieldstr(InventTable, RecId),
int642str(inventTable.RecId));
nodeXml.appendChild(nodeTable);
nodeAccount = doc.createElement(
fieldstr(InventTable, ItemId));
nodeAccount.appendChild(
doc.createTextNode(inventTable.ItemId));
nodeTable.appendChild(nodeAccount);
nodeName = doc.createElement(
fieldstr(InventTable, ItemGroupId));
nodeName.appendChild(
doc.createTextNode(inventTable.ItemGroupId));
nodeTable.appendChild(nodeName);
nodeItemName = doc.createElement(
fieldstr(InventTable, ItemName));
nodeItemName.appendChild(
doc.createTextNode(inventTable.itemName));
nodeTable.appendChild(nodeItemName);
nodeModelGroup = doc.createElement(
fieldstr(InventTable, ModelGroupId));
nodeModelGroup.appendChild(
doc.createTextNode(inventTable.ModelGroupId));
nodeTable.appendChild(nodeModelGroup);
nodeDimGroup = doc.createElement(
fieldstr(InventTable, DimGroupId));
nodeDimGroup.appendChild(
doc.createTextNode(inventTable.DimGroupId));
nodeTable.appendChild(nodeDimGroup);
}
doc.save(#filename);
}
[:)]
Thanks&Regards
Varun Garg
Hi,
Welcome to DUG [:)]
It is not clear what do you mean terminated with ‘0d0a’.
Each nodes in XML will have an opening and closing XML tag. Whereas the hexadecimal character you referred to (0d0a) stands for end of a line character and usually used in generating text files.
Can you give us an example how you want to use this hexadecimal character in XML file? And why you want to implement hexadecimal in XML?
Hello, thanks Varun and Harish, I used the example of Varun, but my problem is still unresolved
the file will be sent to the credit card issuer and this was a requirement of them, at the end of each row has the characters “0d0a”.
An example:
<?xml version="1.0" encoding="iso-8859-1" ?>Thanks and Regards
Wanderson
Hi,
Having had a look at your above XML example, it should be possible to generate this file from AX itself without the need of appending the special character at the end. The end result will be exactly the same as your above example.
Have you tried writing this in AX yet? What issues did you encounter?