The XML document is usually loaded into an XML DOM document object, although the XML document may also be loaded into an XML DSO object or an XML Data Island.

XML DOM Object

Once set, an XML DOM object (aka Microsoft XMLDOMDocument, Msxml2.DOMDocument, XML DOM Document, etc.) has various properties and methods for dealing with an XML document, including loading it, saving it, and accessing and modifying its data nodes.

Set an XML DOM object. EGs: In these examples, different versions of the object are shown but only one version should be used in a given environment.

Load an XML document into the XML DOM object by one of several means:

Here is a JavaScript example that shows some of the more important members of the XML DOM object. It is possible to load the XML document asynchronously (i.e. load while the rest of the HTML document is loading) but it is best to do it synchronously.

<script type="text/javascript">
var objDOM1 = new ActiveXObject("Msxml2.DOMDocument");
objDOM1.async = false;
if (objDOM1.parseError == 0){
  //access data in the object since no error occurred

Here is a JavaScript example that shows how to set and load in Mozilla or Internet Explorer. Via "Migrate apps from Internet Explorer to Mozilla" []

var xmlString = "<xml id=\"xmldataisland\"><foo>bar</foo></xml>"; 
var myDocument; 

if (window.DOMParser) {
  // This browser appears to support DOMParser
  var parser = new DOMParser(); 
  myDocument = parser.parseFromString(xmlString, "text/xml"); 
} else if (window.ActiveXObject){ 
  // Internet Explorer, create a new XML document using ActiveX 
  // and use loadXML as a DOM parser. 
  myDocument = new ActiveXObject("Microsoft.XMLDOM"); 
  myDocument.async = false; 
} else {
  // Not supported.

XML Data Island

XML data and documents can be embedded into HTML via XML data islands. Data island objects and XML DSOs can both be directly bind HTML objects to the data, but data islands are much simpler to initialize.

Here are different ways to make a data island, but the last three ways are deprecated.

  1. <!-- XML document via its URL using an "xml" tag. / -->
    <xml id="myIsle" src="myData.xml">
  2. <!-- XML data inline using an "xml" tag. / -->
    <xml id="myIsle">
  3. <!-- XML data inline using type set to "text/xml". / --> <script id="myIsle" type="text/xml">
  4. <!-- XML data inline using language set to "xml". / --> <script id="myIsle" language="xml">
  5. <!-- The last two cases can also get an XML document via its URL. / --> <script id="myIsle" language="xml" src="">

Data islands can be made available via the MS IE HTML DOM object (which is distinct from the MS XML DOM object). EGs:

MS IE can also access data islands more directly with a datasrc attribute. EG:

<xml id="myIsle">
<!-- Assume the isle has "rows"with "fields" of "date" and "event" -->
<table datasrc="#myIsle">
   <td><div datafld="date"></div></td>
   <td><div datafld="event"></div></td>
<input type="button" value="First Page" onclick="tbl.firstPage();">


XML DSOs (Data Source Objects) can be used like an XML DOM object but it also has two major advantages:

However, the XML DSO also has two major drawbacks:

The XML DSO is created with an <object> tag within HTML code. The loading is commonly triggered with the onload event of the body so that the process occurs synchronously.

The <object> tag can point to an XML document via its URL or by enclosing XML data inline. EGs:

Page Modified: (Hand noted: ) (Auto noted: )