The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
IMPORT Method (XMLport)
Reads and parses an incoming XML data stream (XML document).
[Ok :=] XMLPORT.IMPORT(Number, InStream[, Record])
The ID of the XMLport that you want to run.
If the XMLport that you specify does not exist, a run-time error occurs.
The source from which the import XMLport object will read the XML data stream.
The record to use in the XMLport. Any filters that are attached to the record will be used.
This parameter is optional. If this parameter is omitted, all records in the table are imported.
For example, you can use this parameter to change the values of properties such as FieldSeparator or TextEncoding, depending on each record that is imported.
The following example imports data from an XML document to a table. The code uses the OPEN Method (File) to open the XML document named NewCustomer.xml from a folder named Import on the C: drive. The CREATEINSTREAM Method (File) creates a data stream to get the data from the XML document to the table. The IMPORT Method (XMLPORT) then imports, parses the data and adds it as a record to the table by using an XMLport (50004). The CLOSE Method (File) then closes the data stream. This example assumes that you have created a NewCustomer.xml file in a folder named Import on the C drive and you have created an XMLport and given it ID 50004. This example requires that you create the following global variables.
ImportXmlFile.OPEN('C:\Import\NewCustomer.xml'); ImportXmlFile.CREATEINSTREAM(XmlINStream); XMLPORT.IMPORT(50004, XmlINStream); ImportXmlFile.CLOSE;