Compartir a través de


How to: Design XMLports

You design XMLports to export data from Microsoft Dynamics NAV tables or import data to a Microsoft Dynamic NAV tables. You can design XMLports to import or export XML documents, variable text files, or fixed-width text files.

To design an XMLport

  1. In the Microsoft Dynamics NAV Development Environment, on the Tools menu, choose Object Designer.

  2. In Object Designer, choose XMLport, and then choose the New button to open XMLport Designer.

  3. On the View menu, choose Properties to open the XMLport-Properties window.

  4. In the XML-Properties window, set the Direction Property. If you want to export data, set the property to Export. If you want to import data, set the property to Import.

  5. Set the Format Property (XMLports) to the format of the document you want to import or export. You can set the format property to Xml, Variable Text or Fixed Text. By default the format property is set to Xml.

  6. If you set the format property to variable text, then do the following:

    1. Set the following properties. By default these properties are set as shown in the table but you change the values.

      Property Value

      TextEncoding Property

      <MSDOS>

      FieldDelimiter Property

      FieldSeparator Property

      ,

      RecordSeparator Property

      <NewLine>

      TableSeparator Property

      <NewLine><NewLine>

    Note

    If you are importing a text file, you must examine the text file to determine the appropriate values for these properties.

  7. If you set the file format to fixed text, then do the following:

    1. Set the following properties. By default, these properties are set as shown in the following table but you can change the values.

      Property Value

      TextEncoding Property

      <MSDOS>

      RecordSeparator Property

      <NewLine>

      TableSeparator Property

      <NewLine><NewLine>

    Note

    If you are importing a text file, you must examine the text file to determine the appropriate values for these properties.

  8. In XMLport Designer, in the first row, in the Node Name column, enter a name

    Note

    If the document that you want to import or export is an XML file, then you must enter Root in the Node Name column. Root indicates the beginning of XML documents

  9. In the Node Type column, select Element.

  10. In the Source Type column, select Text.

    This element represents the start of the document you want to import or export.

  11. In the Data Source column, verify that the value is the same as the name of the node.

  12. In the second row, in the Node Name column, enter a name for the table you want to export or import.

  13. In the Node Type column, select Element.

  14. In the Source Type column, select Table.

  15. In the Data Source column, choose the arrow to open the Table List.

  16. From the Table List, select the table you want to export from or import to.

  17. Choose the right arrow to indent the row one time to make the row a subset of the top row.

  18. In the next row, in the Node Type column, choose Element.

  19. In the Source Type column, select Field

  20. In the Data Source column select the field you want from the Field Lookup window.

  21. In the Node Name column, enter a name for the field. For consistency you can enter the same name as the field you selected.

  22. Indent the field row one time to make it a subset of the table row.

  23. Repeat steps 18 through 21 to select all the fields you want to export or import.

  24. If the format of the file is fixed text, then for each field, set the Width property to an appropriate value.

    Note

    If the value of the Width property is less the width of a field, the data in the field will be truncated.

  25. From the File menu, choose the Save As button.

  26. In the Save As window, enter an ID and a name for the XMLport, and verify that Compile is selected, and then choose the OK button to save the XMLport.

See Also

Concepts

Designing XMLports

Other Resources

XMLport Walkthroughs