[jdom-interest] XPATH Question

Sanjeev Verma [CONTRACTOR] sanjeev.verma at Sun.Com
Thu May 8 15:23:53 PDT 2003


Hi all:

Although I am using JDom in my application, this is purely an XPath question.

I have an XML document, that has a "*" as the multiplicity assigned to an 
element. This element, lets say category, is defined to have a PCDATA value and 
an attribute called "level", which can be 1, 2, 3...

My problem is, I need an XPath expression by which I can select parent node of 
all such category elements whose PCDATA value equals "certain string" and whose 
attribute "level" equals "certain level". I used an expression like:

/.../parent-tag[category="certain string" and category[@level=certain_level]]

But this expression gives erroneous output, because of the multiplicity of this 
element. What I get is a list of <parent-tag> where ANY category element has 
PCDATA equals "certain string" and ANY OTHER category element attribute level 
equals "certain level". That is, it is not the same category element that is 
being used for comparison.

Is the problem statement clear? can someone help?

Best Regards

Sanjeev




More information about the jdom-interest mailing list