HTML Exec with external XML file (SOLVED)

It’s possible to read data from an external file (text or XML, it doesn’t matter) and access the contents from JavaScript. For security reasons, you’ll have to use HEScript functions.

Here is the code example (insert it in UserMain):

uses Classes; // Add this to the top of the script  

function ReadXMLFile(Filename: String): String;
var
T: TStringList;
S: String;
begin
T := TStringList.Create;
try
// Loads the XML file in the same path as the ebook EXE file.
EbookPath := GetGlobalVar("HEPublicationPath", "");
S := EbookPath + Filename;
T.LoadFromFile(S);
 // Gets the contents.
Result := T.Text;
finally
T.Free;
end;
end;  

Now you can call this function from JavaScript. Suppose that the XML file is named mydata.xml and is available in the same folder as the EXE file:

var s = window.external.GetHEScriptCom('usermain.ReadXMLFile|mydata.xml', 'none');
alert(s);

Then your s variable contains the contents of the XML file.

Hello,

Can I use HTML-Exec to create an exec who can read an external xml file (with Jquery script) ?
If yes, how to insert the Jquery script ?

Thank you,

Bests regards.

Hello,

HTML Exec is fantastic :smiley:
Thank you so much for your help!

Bests regards

This topic was automatically closed after 24 hours. New replies are no longer allowed.