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

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Sep 1 06:16:49 PDT 2004


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


More information about the jdom-interest mailing list