Reading files in JavaScript -- using XML (data islands and
Active X)
lesson in seven steps(only for Internet Explorer)
- Simple
example (field names known)
- Generalization
(load one field at a time, with field names known)
- Parsing
an XML file (with a very shallow tree), turning off the
asynchronous pause, and traversing xmlDoc.documentElement.ChildNodes
- A
simpler way? (using XML data islands) Data islands are little
things, sort of like <embed>s in an HTML document.
- Reading XML, HTML, or .txt files
Shallow trees but simple code.
- Parsing deeper trees -- Reading and
parsing XML, plain text, and HTML files, recursively.
- 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