Reading XML files in JavaScript
- Something that
works in both FF and IE but not Chrome or Safari perhpas it is instructive
-
Something that seems to work everywhere
Some old things for IE only
- Simple example
(field names known) --
- Generalization
(load one field at a time, with field names known) -- Starting
toward cross browser
- 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