[jdom-interest] getElementsByTagName()

Jason Hunter jhunter at acm.org
Mon Jul 10 10:34:23 PDT 2000


> Celia Bohle wrote:
> 
> Hello,
> 
> Is there anything in JDOM which is similar to the DOM method
> getElementsByTagName(name)? This method returns a list of Element
> nodes that have a property tagName that matches the parameter name.
> The important thing is that this method searches the whole subtree of
> the Element that it was called on.

There's no method that walks all the descendents of an element. 
getChild() walks only the direct children.  The way JDOM is going to
deal with such requirements as yours is by supporting XPath, where you
can do extremely powerful lookups including the one you want.  In the
meanwhile, since we don't want to add methods that we know we'll
deprecate, what you can do is create a utility class that does the
walking for you.  Should take 5 minutes to write.

-jh-





More information about the jdom-interest mailing list