You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Greg Matthews <gm...@flex.com.au> on 2000/01/07 05:00:23 UTC
TreeWalker
Hi,
I've been looking to convert from using the Java TR-2 xml package
to Xerces 1.0.1.
Haven't had much success in finding an equivalent for
TreeWalker.getNextElement( <tagName> );
I can create a TreeWalker and go through the nodes but...
1. wonder if there is an equivalent of the above, or i have
to just loop through nodes myself until i get to the node
i need.
2. would like to know if there's an easy way to skip over
elements in a doc without drilling down to lower levels
in the tree. e.g.
<TOP><A><B/><A/><A><B/></A><A/></TOP>
is there a way to create the treewalker at the <TOP> level then
just have it iterate over the <A> nodes, where in the example
above all the <B> nodes happen to be child elements to the <A>'s.
Thanks
Greg.
PS. Is someone going to start putting in a few more javadoc
comments anytime soon? A few more helpful comments
would be really good.
Re: TreeWalker
Posted by Ralf Pfeiffer <rp...@apache.org>.
If you take a look at the factory member function for TreeWalker,
you can specify a nodetype or set of nodetypes which the treewalker will
walk, and ignore the rest. You can also set up a filter in which you
override
an acceptNode function, and accept some nodes, filter out others.
A UI we use for testing the TreeWalker implementation can be found in
the samples dir: dom.traversal.TreeWalkerView. It gives an example of
using a filter based on node name.
-rip
Greg Matthews wrote:
> Hi, I've been looking to convert from using the Java TR-2 xml
> packageto Xerces 1.0.1. Haven't had much success in finding an
> equivalent for TreeWalker.getNextElement( <tagName> ); I can create a
> TreeWalker and go through the nodes but... 1. wonder if there is an
> equivalent of the above, or i have to just loop through nodes
> myself until i get to the node i need. 2. would like to know if
> there's an easy way to skip over elements in a doc without drilling
> down to lower levels in the tree. e.g.
> <TOP><A><B/><A/><A><B/></A><A/></TOP> is there a way to create the
> treewalker at the <TOP> level then just have it iterate over the
> <A> nodes, where in the example above all the <B> nodes happen to
> be child elements to the <A>'s. ThanksGreg. PS. Is someone going to
> start putting in a few more javadoc comments anytime soon? A few
> more helpful comments would be really good.