Reads and parses an incoming XML data stream (XML document).

[Ok :=] XMLPORT.IMPORT(Number, InStream[, Record])

Parameters

Number

Type: Integer

The ID of the XMLport that you want to run.

If the XMLport that you specify does not exist, a run-time error occurs.

InStream

Type: ISequentialStream

The source from which the import XMLport object will read the XML data stream.

Record

Type: Record

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.

Example

The following example imports data from an XML document to a table. The code uses the OPEN Function (File) to open the XML document named NewCustomer.xml from a folder named Import on the C: drive. The CREATEINSTREAM Function (File) creates a data stream to get the data from the XML document to the table. The IMPORT Function (XMLport) then imports, parses the data and adds it as a record to the table by using an XMLport (50004). The CLOSE Function (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 variables in the C/AL Globals window.

Variable name DataType

ImportXmlFile

File

XmlINStream

InStream

 Copy Code
ImportXmlFile.OPEN('C:\Import\NewCustomer.xml');
ImportXmlFile.CREATEINSTREAM(XmlINStream);
XMLPORT.IMPORT(50004, XmlINStream);
ImportXmlFile.CLOSE;

See Also