I think your implementation is okay, you might just be using the wrong
tool. I haven't used the xml parsers that are demonstrated in the examples
you've been looking at, but I think the xml for js parsers are more straigt
forward. I put together this example for you using the labels xml example.
You can access it at
http://millstone.iodp.tamu.edu/~blambi/xmljs/labels.html<http://millstone.iodp.tamu.edu/%7Eblambi/xmljs/labels.html>.
The interesting part is this:
function loadXmlData(xmlText)
{
var parser = new DOMImplementation();
var domDoc = parser.loadXML(xmlText);
var root = domDoc.getDocumentElement();
var ls = root.selectNodeSet('//label');
var count = ls.getLength();
var text = "<h5>There are " + count + " labels in this document with the
following names:</h5>";
text += "<ul>";
for (var i = 0; i < count; i++)
{
var nameNode = ls.item(i).selectNodeSet("name").item(0);
text += "<li>" + nameNode.getFirstChild () + "</li>";
}
text += "</ul>";
document.getElementById('info').innerHTML = text;
}
This just loads the xml text and then does a selectNodeSet to get the labels
and then another to get the name. This is a much simpler approach than
messing around with types like that other example has you doing. This
mostly follows the tutorial at
http://xmljs.sourceforge.net/website/contributedAddOns-xpath-documentation.html
Brice
|