HTML Exec with external XML file (SOLVED)

Status
Not open for further replies.

stony

New member
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.
 
Last edited:
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):
Code:
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:
Code:
var s = window.external.GetHEScriptCom('usermain.ReadXMLFile|mydata.xml', 'none');
alert(s);
Then your s variable contains the contents of the XML file.
 
Last edited:
Hello,

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

Bests regards
 
Last edited:
Status
Not open for further replies.
Back
Top