XML (Standard)

Extensible Mark-up Language.

This is gradually becoming commonplace as a way to exchange data between systems. It is also supported by the MSIE browser and you can load in XML documents directly.

It is the future direction that HTML is evolving towards, beginning with XHTML.

This topic is the entry point to a completely new subject area. Its too vast to attempt to cover it meaningfully in just a few pages and yet it's probably going to become one of the most important parts of the web programming landscape.

Refer to the Wrox's beginning and professional XML books for details of how to use it in earnest. Here we will just scratch the surface to begin to see what it looks like.

This creates a new XML document via ActiveX:

   myXMLDoc = new ActiveXObject("Microsoft.XMLDOM");

Having created it, now we can load the contents of a URL into the object:


This is useful because one big problem with JavaScript in a web browser is that it's very hard to download a data file from a web server to a script, without having to work around lots of security issues. This might solve that problem a lot more elegantly.

Now we can begin to look at the contents of the file and extract information from it.


Now that we have acquired the document we can use the DOM navigation techniques that already work for HTML documents to walk through the XML structures:

   var myXMLNodeList = myXMLDoc.getElementsByTagName(strNodeName);