January 30, 2002 - Waiting for XML Loading | WebReference

January 30, 2002 - Waiting for XML Loading

Yehuda Shiran January 30, 2002
Waiting for XML Loading
Tips: January 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

There are two ways to list the content of the DOMDocument object. Our first display shows only the data-related elements of the object. You accomplish this by asking for the xml property of the root element, xmldoc.documentElement. The load1() function demonstrates this presentation:

function load1() {
  var xmldoc;
  xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmldoc.async = false;
  xmldoc.load("mydvd.xml");
  alert(xmldoc.documentElement.xml);
}
Try it now. You should get the mydvd store file, with just the data elements.

Our second display includes all items in the XML file, including the directives in the beginning of the file, such as the XML version or the XSL file name. You accomplish this by asking for the xml property of the DOMDocument object. The load2() function demonstrates this presentation:

function load2() {
  var xmldoc;
  xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmldoc.async = false;
  xmldoc.load("mydvd.xml");
  alert(xmldoc.xml);
}
Try it now. You should get the mydvd store file, with all initial settings and directives.