web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Creating XML

Hossein.K Profile Picture Hossein.K 6,648
Extensible Markup Language (XML) is a text-based standard for representing
data and is commonly used for data exchange and business
-to-business
communication.
The structure of XML files is similar to HTML in that it uses tags to define
sections of the file. Each tag defines either single or groups of data elements, and
can also have attributes (for example, a date or reference ID) attached to the tag.
The following is an example of a simple XML file:



1
2
3
4
5
<note>
<appl>Microsoft Dynamics AX</appl>
<version>2012</version>
<body>This is a simple XML file</body>
</note>

Since it is a simple text file, it is possible to create an XML file using Microsoft
Dynamics AX AsciiIO class, and to ensure that all the tags are correctly
formatted and positioned. Be careful though as the tags are case
-sensitive.
Alternatively, Microsoft Dynamics AX includes a wrapper for the COM object
microsoft.xmldom, which creates the file using tag names and data.
The following example creates an XML file containing employee names and
addresses:


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
static void XMLWriteEmplAddr(Args _args)
{
FileIoPermission permission;
XMLDocument xmlDoc =
XMLDocument::newBlank();
XMLNode rootNode;
XMLNode NodeEmpl, NodeName, NodeAddr;
XMLElement xmlElement;
XMLText xmlText;
HCMWorker HCMWorker;
;
permission= new

FileIoPermission('c:\\Empl_Address_List.xml','w');
permission.assert();
xmlDoc = XMLDocument::newBlank();
// Create first line containing version info
rootNode = xmlDoc.documentElement();
xmlElement =
xmlDoc.createElement(‘EmployeeList’);
rootNode = xmlDoc.appendChild(xmlElement);
while select EmplTable
{
// Create a node for the Employee record
xmlElement =
xmlDoc.createElement(‘Employee’);
NodeEmpl = rootNode.appendChild(xmlElement);
// Create a node for the name
xmlElement =
xmlDoc.createElement(‘EmplName’);
NodeName =
NodeEmpl.appendChild(xmlElement);
xmlText =
xmlDoc.createTextNode(EmplTable.Name());
NodeName.appendChild(xmlText);
// Create a node for the address
xmlElement =
xmlDoc.createElement(‘EmplAddr’);
NodeAddr = NodeEmpl.appendChild(xmlElement);
xmlText =
xmlDoc.createTextNode(EmplTable.Address);
NodeAddr.appendChild(xmlText);
}
// Save the file
xmldoc.save('c:\\Empl_Address_List.xml');
}

Best Regards,
Hossein Karimi

Comments

*This post is locked for comments