XMLports – What are they and how to use them

XMLports was introduced with Navision 4.0 – they act like dataports, with a small difference. They can only be used for XML-formatted data and they must by executed from some other routine.

In the XMLport designer – you set up a defined format. Just think of it, as a kind of schema (xsd). You can add Elements and Attributes and in the Properties you can setup the Encoding and the DefaultNamespace.


Now that the XMLport has been designed, it is time to use it.

An XMLport, can as already mentioned, not be executed by itself. You have to call it from another routine. Such as a codeunit, forms etc.

To export XMLs do the following:

First create an Out File - this are what you xml will be called:


Next prepare for streaming the data to XML. In Designer example we used 
Sales Header. So the out stream is called SH_outStream:


Now that we have the out File and the out stream ready it is time to execute
the XMLport. This is done by calling the export:

      XMLPORT.EXPORT(50000, SH_outStream);

And then finally end by closing the file.


The exported XML file will look like this:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
                <itemno quantity="4" price="0">ITEM-No-10</itemno>
                <description>This is a item description</description>

Importing XML files is similar to the Export:

First open the file:


Next create an in stream:


And then execute the XMLport to importing the xml:

      XMLPORT.IMPORT(50000, SH_inStream);

And then finally end by closing the file:


That’s all – now you can export and import xml files using an XMLport.

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.