views:

23

answers:

1

hi all I'm trying to parse a DOM tree using Neko/Xerces in Java.

NodeList divs = this.doc.getElementsByTagName("DIV");
for(int i=0; i < divs.getLength(); i++) {

    NodeList images = divs.item(i).parentNode().getElementsByTagName("IMG");

// operate on these

}

is what I'd ideally like to do. It seems I can only call getElementsByTagName on the document itself? Am I doing something wrong? Should I be able to call that on a Node element?

I can see from the docs it's not there: http://xerces.apache.org/xerces-j/apiDocs/org/w3c/dom/Node.html so maybe I need to do it another way?

thanks!

A: 

Yeah, that's weird. Python's xml.dom.minidom has a Node.getElementsByTagName. Maybe it's not part of the standard. Instead, you could iterate an inner loop over divs.item(i).parentNode().getChildNodes().

altie