{"title":"Defining an XMLport schema","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-xmlport-schema/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-xmlport-schema, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-xmlport-schema","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"An XMLport schema determines which data is exported from or imported to Dynamics 365 Business Central database tables and the format and structure of the files used.","date":"2026-08-24","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Defining an XMLport schema","slug":"defining-an-xmlport-schema","at":0,"chars":3583},{"level":2,"title":"Snippet support","slug":"snippet-support","at":2193,"chars":1165},{"level":3,"title":"Example","slug":"example","at":2394,"chars":964},{"level":2,"title":"Related information","slug":"related-information","at":3358,"chars":225}],"text":"# Defining an XMLport schema\nYou use an XMLport object to export and import data between an external source and Business Central. The schema determines which data and how that data is extracted from or inserted into the Business Central database tables through an XMLport. See devenv-xmlport-object and about designing XMLports in devenv-xmlport-overview.\nYou build the XMLport schema from nodes. A node can be one of the following elements:\n A text element\n A text attribute\n A table element\n A field element\n A field attribute\nYou nest nodes inside other nodes to define the structure of the XMLport schema. Use the following keywords to define the structure.\nKeyword|Description\ntextelement|Defines a new text element in the XMLport. It's used for XML elements that don't map to a database item or when the database doesn't need the information.\ntextattribute|Defines a new text attribute in the XMLport. It's used for XML attributes that don't map to a database item or when the database doesn't need the information.\ntableelement|Defines a new table element in the XMLport. It's used for XML elements that map to a table in the database, which is specified in the properties/devenv-sourcetable-property. When the XMLport is run, the code nested inside the table element is iterated for all records in the underlying table.\nfieldelement|Defines a new field element in the XMLport. It's used for XMLport elements that map to a field in the database, which is specified in the SourceField property<properties/devenv-properties>. You must specify it inside the parent table element of the field.\nfieldattribute|Defines a new field attribute in the XMLport. It's used for XMLport attributes that map to a field in the database, which is specified in the SourceField property<properties/devenv-properties>.\n> NOTE\n> There can only be one `<root>` node, which must be an element. If the properties/devenv-format-property is set to Xml, it must be a textelement node.\nThere can be several attributes for a single element and their order doesn't matter. Attribute nodes must be specified inside the element nodes they refer to and before other element nodes. They can't have nested element nodes.\n## Snippet support\nType the shortcut txmlport to create the basic layout for an XMLport object when you use the AL Language extension for Microsoft Dynamics 365 Business Central in Visual Studio Code.\n### Example\nThe following example adds the Customer table as a table element, the Address field as a field element and the County and City fields as field attributes.\n```al\nschema\n{\n    textelement(Customers)\n    {\n        tableelement(Customer; Customer)\n        {\n            fieldelement(Address; Customer.Address)\n            {\n                fieldattribute(County; Customer.County){}\n                fieldattribute(City; Customer.City){}\n            }\n        }\n    }\n}\n```\nLearn more about designing XMLports in devenv-xmlport-overview.\nLearn more about data consistency and validation against possible errors when using XMLports in the blog post Importing and exporting valid data using XMLports in Dynamics 365 Business Central<https://cloudblogs.microsoft.com/dynamics365/it/2019/05/22/importing-and-exporting-valid-data-using-xmlports-in-dynamics-365-business-central/>.\nLearn more about namespaces in XMLports in devenv-using-namespaces-with-xmlports.\n## Related information\ndevenv-xmlport-object\nmethods-auto/xmlport/xmlport-data-type\ndevenv-using-namespaces-with-xmlports\ntriggers-auto/xmlport/devenv-oninitxmlport-xmlport-trigger\ndevenv-request-pages\ndevenv-xmlport-overview"}