I found an actionscript version of this script quite some time ago. I’ve used it heavily and had need of the same thing in Javascript. So, here’s the JS version of it.
Essentially this script allows you to pass an XMLNode object and it will return a Javascript tree’d object for you. If your xml document looks like this…
<notes> <note id="note 1">This is the text for note 1</note> <note id="note 2">This is the text for note 2</note> </notes>
Then your JS object would give you access like this…
xml.notes.note[0].value
or
xml.notes.note[‘note 1’].value
It also gives you access to the original xmlNode object from which it was derived…
xml.notes.note[0].node.nodeValue