Sharing information through XMLports
XML stands for Extensible Markup Language and is a text format for creating structured computer documents. NAV provides objects called XMLports that allow you to create these types of documents.
How to do it...
Create a new XMLport from Object Designer.
Add the following lines to the XMLport Designer:
Node Name
Node Type
Source Type
Data Source
Root
Element
Text
<Root>
Customer
Element
Table
<Customer>(Customer)
No
Element
Field
<Customer>::No.
Name
Element
Field
<Customer>::Name
Your XMLport should look like this:
Save and close the XMLport.
Create a new codeunit from Object Designer.
Add the following global variables:
Name
DataType
Length
OutputFile
File
OutputStream
OutStream
FileName
Text
255
Add the following code to the
OnRun
trigger:FileName := ENVIRON('TEMP') + 'Customers.xml'; OutputFile.CREATE(FileName); OutputFile.CREATEOUTSTREAM(OutputStream); XMLPORT.EXPORT(51001, OutputStream); OutputFile...