{"title":"Using namespaces with XMLports","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-using-namespaces-with-xmlports/","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-using-namespaces-with-xmlports, 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-using-namespaces-with-xmlports","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":"Learn how to declare namespaces on an XMLport in Business Central and apply namespace prefixes to text, table, and field elements in the XML schema.","date":"2026-08-24","meta":{"topic":"concept-article"},"outline":[{"level":2,"title":"Related information","slug":"related-information","at":2970,"chars":216}],"text":"The external system that provides or consumes AL Language development environment data as XML might require that the XML documents include namespaces. Namespaces are used to avoid element name conflicts. In these cases, you must add namespaces on the XMLport to make it compatible with the XML schema that is used by the external system.\n> NOTE\n> Namespace-related properties are only available when the properties/devenv-format-property is set to Xml.\nFor example, the following code is a portion of a simple XML document for transferring sales order information. The XML includes namespaces for mapping fields from the `Sales Header` table.\n```xml\n<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n<Root xmlns=\"urn:bc:schema:all\" xmlns:bcField=\"urn:bc:schema:field\" xmlns:bcTable=\"urn:bc:schema:table\">\n  <bcTable:SalesHeader>\n    <bcField:DocType>Order</bcField:DocType>\n    <bcField:DocNo>101005</bcField:DocNo>\n    <bcField:SellToCustNo>30000</bcField:SellToCustNo>\n    <bcField:SellToCustName>John Haddock Insurance Co.</bcField:SellToCustName>\n    <bcField:BillToCustNo>30000</bcField:BillToCustNo>\n    <bcField:BillToCustName>John Haddock Insurance Co.</bcField:BillToCustName>\n  </bcTable:SalesHeader>\n...\n</Root>\n```\nEach namespace has the syntax xmlns:prefix=\"namespacename\".\n The namespacename is a string of characters, often referred to as a Uniform Resource Identifier (URI), which uniquely identifies an internet resource. This string is typically a Uniform Resource Locator (URL) or Universal Resource Name (URN).\n The prefix is a short string of characters that acts as an alias for the namespace name. The prefix is applied to specific elements in the XML document. The example includes the prefixes bcField and bcTable.\n A namespace that doesn't include a prefix declares the default namespace. In the example, the default namespace is `urn:bc:schema:all`. The default prefix applies to all the elements that don't include a prefix.\nDeclare the namespaces used in the XMLport by using the properties/devenv-namespaces-property. For each namespace, specify a prefix and a namespace name. You can declare a default namespace by defining an empty prefix `\"\"`. In the XML documents that the XMLport exports or imports, you can only include namespace declarations in the `<root>` element.\nApply the namespaces to XMLport elements by setting the properties/devenv-namespaceprefix-property of the element to one of the namespace prefixes declared in the properties/devenv-namespaces-property. This property only applies to textelement, tableelement, and fieldelement nodes. Otherwise, it's ignored.\nYou can also specify a default namespace by using the properties/devenv-defaultnamespace-property and setting the properties/devenv-usedefaultnamespace-property to true. There can only be one default namespace, so if you specify the default namespace in the properties/devenv-namespaces-property, you must set the properties/devenv-defaultnamespace-property to false.\n## Related information\ndevenv-xmlport-object\nproperties/devenv-namespaces-property\nproperties/devenv-namespaceprefix-property\nproperties/devenv-defaultnamespace-property\nproperties/devenv-usedefaultnamespace-property"}