Now You can create an xml file of the table using the following code
void CreateItemXML()
{
XmlDocument xmlDoc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeItem;
XmlElement nodeName;
XmlElement nodeGroup;
XmlElement nodeType;
InventTable inventTable;
#define.filename('e:\\item.xml')//Location of item xml file
;
xmlDoc = XmlDocument::newBlank();
nodeXml = xmlDoc.createElement('xml');
xmlDoc.appendChild(nodeXml);
//Creates xml for all the items which have the ItemGroupId "Television"
while select inventTable where inventTable.ItemGroupId == "Television"
{
nodeTable = xmlDoc.createElement(tablestr(InventTable));
//Add RecId as an attribute
nodeTable.setAttribute(fieldstr(InventTable, RecId),
int642str(inventTable.RecId));
nodeXml.appendChild(nodeTable);
//Add ItemId as a node
nodeItem = xmlDoc.createElement(fieldstr(InventTable, ItemId));
nodeItem.appendChild(xmlDoc.createTextNode(inventTable.ItemId));
nodeTable.appendChild(nodeItem);
//Add Item name as a node
nodeName = xmlDoc.createElement(fieldstr(InventTable, ItemName));
nodeName.appendChild(xmlDoc.createTextNode(inventTable.ItemName));
nodeTable.appendChild(nodeName);
//Add Item group as a node
nodeGroup = xmlDoc.createElement(fieldstr(InventTable, ItemGroupId));
nodeGroup.appendChild(xmlDoc.createTextNode(inventTable.ItemGroupId));
nodeTable.appendChild(nodeGroup);
//Add Item type as a node
nodeType = xmlDoc.createElement(fieldstr(InventTable, ItemType));
nodeType.appendChild(xmlDoc.createTextNode(strfmt("%1",inventTable.ItemType)));
nodeTable.appendChild(nodeType);
}
xmlDoc.save(#filename);
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
Subscribe to:
Post Comments (Atom)
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->...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...
Why doesent this code print melding xsi:schemalocation?
ReplyDeleteIt prints d1p1:schemalocation!
permission.assert();
xmlDoc = new XMLDocument();
xmlRoot = xmldoc.CreateElement("Root");
xmlRoot = xmlDoc.documentElement();
xmlpi = xmlDoc.createProcessingInstruction('xml', 'version=\"1.0\" encoding=\"utf-8\"');
xmlDoc.appendChild(XMLpi);
xmlMelding = xmlDoc.createElement('melding');
xmlMelding.setAttribute2('schemaLocation','http://www.w3.org/2001/XMLSchema-instance', 'urn:ske:fastsetting:innsamling:saldoRente:2.0 saldoRente:2.0.xsd');
xmlMelding.setAttribute('xmlns', 'http://www.w3.org/2001/XMLSchema-instance');
xmlMelding.setAttribute('xmlns', 'urn:ske:fastsetting:innsamling:saldoRente:2.0');
xmlLeveranse = xmlDoc.createElement('Leveranse');