Partager via


Source: LoadXMLFile.js

 

The following code snippet loads an XML file from the current directory into an XML DOM object. In JScript, the current directory is represented by the App.Path property.

JScript Source File (LoadXMLFile.js)

// Instantiate a DOM object.
var doc = new ActiveXObject("msxml2.DOMDocument.6.0");
doc.async = false;
doc.resolveExternals = false;
doc.validateOnParse = false;

// Load an XML file into the DOM instance.
doc.load("test.xml");

// Display the content of the object.
alert("doc: "+doc.xml);

// Helper function:
function alert(str)
{
   WScript.Echo(str);
}

Try It!

  1. Copy the code listing above. Paste it into the JScript code editor, and save the file as LoadXMLFile.js in the current project folder.

Next, we'll add the resource file, test.xml.