Parsing an XML Document the Easy Way
Once you've read an XML document into memory, like this...
var xmlDocHolder = new ActiveXObject("MSXML2.DOMDocument")
xmlDocHolder.load("http://www.davidwall.com\countryList.xml")
...you can begin to read elements of that document. The document
countrylist.xml contains, in part, this structure:
To refer to data, we refer to a nested series of arrays. The element
containing the data "Japan" would be referred to like this:
JapanNode = xmlDocHolder.childNodes[0].childNodes[1].childNodes[0]
That is, we want to refer to the first (0) element (officialName) of
the second (1) element (country) of the first (0) element
(countryList). The word "Japan" itself -- the data -- would be
referenced as:
JapanText = xmlDocHolder.childNodes[0].childNodes[1].childNodes[0].text
» posted by ITworld staff
ITworld
Essential JavaFX
Get started building rich Web apps quickly with an introduction to the power of JavaFX key features -- scene node graphs, nodes as components, the coordinate system, layout options, colors and gradients, custom classes with inheritance, animation, binding, and event handlers.Enter now!
The Nomadic Developer
Consulting can be hugely rewarding, but it's easy to fail if you are unprepared. To succeed, you need a mentor who knows the lay of the land. Aaron Erickson is your mentor, and this is your guidebook. Enter now!












