AL icon indicating copy to clipboard operation
AL copied to clipboard

Import XML file into XML document in extension

Open Bobby7878 opened this issue 8 years ago • 1 comments

Hi, Can anyone help me with how to import an existing xml file into a xmldocument? I have used the function xmldocument.load(path) before, but I can not use that in an extension.

thanks.

Bobby7878 avatar Dec 23 '17 11:12 Bobby7878

Hi, I have used the following code, which uses UploadIntoStream to load the xml file into an Instream, then XmlDocument.ReadFrom to read the stream into an xmldocument. Hope it helps.

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

end

jennisoliman avatar Jan 12 '18 09:01 jennisoliman