Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] Question about using Xpath whilst using jdom
 beta 10

Laurent Bihanic

2004-09-01

Replies:


Bush, Chris wrote:
> I am new to Jdom and have a question. I am trying use the following code to
> extract out "legIds" from the attached xml. However, I seem to get the same
> legId value twice, rather than the 2 distinct values I am expecting. Am I
> doing something wrong ?

Your second XPath expression is incorrect:
    XPath legpath = XPath.newInstance("//legId");

An XPath expression starting with "//" is evaluated from the document root.
What you what is an expression which is relative to the current node.
Try with ".//legId" (the dot in first position makes it relative).

Laurent
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.