
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,
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);