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
Sign up for ITworld's Daily newsletter
Follow ITworld on Twitter @IT_world
Esther Schindler
If the comments are ugly, the code is ugly
claird
SVG a graphics format for 21st century
pasmith
Take Chrome OS for a test spin
Sandra Henry-Stocker
Solaris Tip: Have Your Files Changed Since Installation?
jfruh
Android fragments vs. the iPhone monolith
mikelgan
What Gizmodo missed about the Pro WX Wireless USB disk drive
Sidekick: The Good News & the Bad News
Either way you look at it Microsoft Data Center management did not follow standards or best practices in this failure. In which case it makes me wonder more about the outsourcing of corporate data much less personal data.
- mburton325
Join the conversation here
Quick, practical advice for IT pros. Made fresh daily.
Want to cash in on your IT savvy? Send your tip to tips@itworld.com. If we post it, we'll send you a $25 Amazon e-gift card.













