Handling XML and JSON files with the AL language

The AL language extension has native support for handling XML and JSON documents.

An XML document is represented by using the XmlDocument data type, as explained at https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/xmldocument/xmldocument-data-type.

The following code shows how you can import an XML file and load it into an XmlDocument object:

local procedure ImportXML()    var        TempBlob : Codeunit "Temp Blob";        TargetXmlDoc : XmlDocument;        XmlDec : XmlDeclaration;        Instr: InStream;        filename: Text;    begin        // Create the Xml Document        TargetXmlDoc := XmlDocument.Create;        xmlDec := xmlDeclaration.Create('1.0','UTF-8',''); TargetXmlDoc.SetDeclaration(xmlDec); ...

Get Mastering Microsoft Dynamics 365 Business Central now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.