JavaScript
JavaScript
Load XML from a Remote URL
Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xml
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new CkHttp();
var sbXml = new CkStringBuilder();
// Download the XML from the URL into sbXml
success = http.QuickGetSb("https://www.chilkatsoft.com/hamlet.xml",sbXml);
if (success == false) {
console.log(http.LastErrorText);
return;
}
var xml = new CkXml();
// Load the XML contained in sbXml
success = xml.LoadSb(sbXml,true);
if (success == false) {
console.log(xml.LastErrorText);
return;
}
console.log("Success.");