Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum

Load XML files in AL programming

(0) ShareShare
ReportReport
Posted on by 10

Hello,

Anyone help me, how can i load the xml file in AL programming. Code in CAL is like below.

procedure ReadXMLFile(FileName: Text)
variables 
XMLDOMManagement: Codeunit "XML DOM Management";
PackageXML: DotNet XmlDocument;
Begin
XMLDOMManagement.LoadXMLDocumentFromFile(FileName,PackageXML);
END;

I have tried the XmlDocument.ReadFrom but it is only useful when i have the xml in text variable.

Thanks,

Categories:
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Load XML files in AL programming

    You have to use XMLDocument object and load the XML file in a InStream object.

    Something like:

    var

    Tempblob : Record Tempblob;

    TargetXmlDoc : XmlDocument;

    XmlDec : XmlDeclaration;

    begin

    // Create Xml Document

    TargetXmlDoc := XmlDocument.Create;

    xmlDec := xmlDeclaration.Create('1.0','UTF-8','');

    TargetXmlDoc.SetDeclaration(xmlDec);

    // Create Instream & upload file into it              

    Tempblob.blob.CreateInStream(Instr);

    filename := 'Content.xml';

    filepath := 'C:\Temp';

    UploadIntoStream('Window Title',filepath,'',filename,Instr);

    // Read stream into new xml document        

    Xmldocument.ReadFrom(Instr, TargetXmlDoc);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans