Getting DOM NodeList by TagName under specific point in DOM Tree?

Hi,

Is there an easy way (or already API call) that one can use to get a DOM NodeList returned based on searching on TagName, BUT only nodes under a specific point in the DOM tree?

That is, effectively I want to do a "document.getElementsByTagName(_string)", but be able to specific the starting node (ie not from the root).

Thanks in advance

Greg

[378 byte] By [gcallagha] at [2007-9-19]
# 1
I am looking for the same answer. Any ideas?Thanks,Dan
dupdupa at 2007-7-8 > top of java,Enterprise & Remote Computing,Enterprise Technologies...
# 2

You can use the xpath api:

import org.apache.xerces.parsers.DOMParser;

import org.apache.xpath.XPathAPI;

/* Use any parser you want here */

DOMParser parser = new DOMParser();

parser.parse(inputFile);

doc = parser.getDocument();

/* Lookup using Xpath */

String xpath = "//TagToSearchFor";

NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);

etc...

jbrightlya at 2007-7-8 > top of java,Enterprise & Remote Computing,Enterprise Technologies...
# 3
element.getElementsByTagName(_string)element-Element Node
dvohra09a at 2007-7-8 > top of java,Enterprise & Remote Computing,Enterprise Technologies...