Reading files in JavaScript -- using XML (data islands and Active X)

lesson in seven steps(only for Internet Explorer)

  1. Simple example (field names known)
  2. Generalization (load one field at a time, with field names known)
  3. Parsing an XML file (with a very shallow tree), turning off the asynchronous pause, and traversing xmlDoc.documentElement.ChildNodes
  4. A simpler way? (using XML data islands) Data islands are little things, sort of like <embed>s in an HTML document.
  5. Reading XML, HTML, or .txt files Shallow trees but simple code.
  6. Parsing deeper trees -- Reading and parsing XML, plain text, and HTML files, recursively.
  7. Examining files in JavaScript -- Reading, parsing and displaying XML, plain text, and HTML files, recursively.

These examples use statements like

var xmlDoc=new ActiveXObject("microsoft.xmldom");
xmlDoc.load("Intro.xml");

or

<xml id="xq" src="Intro.xml"></xml>

to affiliate file contents with JavaScript variables.


using datasrc="#ChunkOfXML"

Here's an example that embeds XML directly into an HTML document which, in turn, reads data from the XML.

A similar use of datasrc to read an XML file into HTML without use of JavaScript