Here are two ways that I know of:

1. Use XPath. The Apache XPath API is a part of the Xalan distribution
2. The DOM Level2 traversal API ie org.w3c.dom.traversal. Here you
implement a NodeFilter which you can use in conjunction with a TreeWalker.

(1) above is the simplest, (2) is more low level and hence much faster.

-Nikhil

On Mon, 20 Sep 2004, Wayne Johnson wrote:

> I have an XML structure where a specific element is referenced at two levels 
> of the same tree:
>
> <RuleTemplate>
>   <RuleDefinition/>
>   <ConcreteRule>
>     <RuleDefinition/>
>   </ConcreteRule>
> </RuleTemplate>
>
> I'd like to search for all the RuleDefinitions that are children of 
> RuleTemplate, but not the one in ConcreteRule.
>
> The XML maps to the object structures so changing things is not an option.
>
> Up till now I was using getElementsByTagNamegetElementsByTagName, but 
> recently realized it wasn't doing what I thought.
>
> I would have suspected that DOM would have another way to do this, but 
> haven't found any, short of doing it by hand.  Since my interface specifies a 
> NodeList, which I haven't figured out how to edit, I'm kind of stuck.
>
> Any suggestions?
>
> Thanks.
>
>
>
>
>
> ---
> Wayne Johnson,             | There are two kinds of people: Those
> 3943 Penn Ave. N.          | who say to God, "Thy will be done,"
> Minneapolis, MN 55412-1908 | and those to whom God says, "All right,
> (612) 522-7003             | then,  have it your way." --C.S. Lewis
>
> ---------------------------------
> Do you Yahoo!?
> vote.yahoo.com - Register online to vote today!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to