[jdom-interest] newbie question
Robert Koberg
rob at koberg.com
Wed Dec 4 06:01:38 PST 2002
Hi,
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Laurent Bihanic
> Sent: Wednesday, December 04, 2002 5:40 AM
>
> Sylvain.Thevoz at swisscom.com wrote:
> > I would like to see all XML tree.
>
> There is no way in JDOM to get a flat view of the XML tree. You'll have to
> walk the tree (using Element.getChild or getChildren + Iterator) to
> get to the
> elements you are interested in.
> Or... use XPath (see below)
>
> > How do you do if you want to display all contents of the <description> tags?
>
> The easiest way
I definitely see this as the easiest way, but what is the fastest? least memory
intensive?
Should you try to avoid XPath if you are concerned with the fastest (perhaps
there is a way to use the xpath key()?), least memory intensive and just
recursively iterate over the nodes?
Is there something about JDOM that makes XPath in Java much better performing
than using DOM? Or by using XPath do you have the same problems (memory) that
you have with DOM?
thanks for any clarification,
-Rob
>to directly access nodes anywhere in the XML tree is to use
> XPath expressions and an XPath engine that supports JDOM (such as Jaxen
> (www.jaxen.org) or use the latest JDOM from CVS that integrates Jaxen).
> The expression "//description" selects all the <description> elements in the
> document.
>
> With JDOM's latest:
> import org.jdom.xpath.XPath;
>
> XPath desc = XPath.newInstance("//description");
> for (Iterator i=desc.selectNodes(doc).iterator(); i.hasNext(); )
> {
> Element e = (Element)i.next();
> System.out.println(e.getText());
> }
>
> Laurent
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@y
ourhost.com
More information about the jdom-interest
mailing list