Importing XML into Business Central with AL
The post demonstrates how to parse cXML (commerce eXtensible Markup Language) files in Business Central using AL code without specialized XML codeunits. It walks through a practical example of extracting purchase order data from an XML file and populating custom tables, highlighting the hierarchical node-based navigation required for XML parsing.

post Aardvark Labs
"XML files differ from many others in that the XML file should be paired with a definition file."
Key points
- XML is meant to follow a schema (XSD), so code can select fixed node paths and expect the data to be there, unlike typical JSON handling
- The example uses only the built-in XmlDocument, XmlNodeList, XmlNode, XmlElement and attribute types, with nested loops over child elements and no helper codeunits
- cXML dates from 1999, but in practice sources often ignore the definitions, so each one needs its own exception handling
- ParseXML reads the vendor ID, order date and ID, and line quantity, part ID, description, price, currency and unit of measure into custom header and line tables
- The author found the manual approach painful and asks whether readers use XMLports instead
Quotes
- “XML files differ from many others in that the XML file should be paired with a definition file.” (Understanding that XML relies on schema definitions explains why validation against XSD is important for reliable parsing)
- “Because of this strict format we can ask for data within a given node and expect it to be there.” (Justifies why XML parsing uses static node paths rather than the flexible navigation required for JSON)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- table “ARD_cXMLPOHeader”
- table “ARD_cXMLPOLine”
- table 23 “Vendor”
Not found in BC28-30: table “ARD_cXMLPOHeader”, table “ARD_cXMLPOLine”.
Context
- Features: XML document parsing, XmlDocument object handling, Node selection and navigation, Attribute extraction, cXML purchase order import, Hierarchical data drilling
Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.