[jdom-interest] about xpath
bob mcwhirter
bob at werken.com
Tue May 22 14:02:57 PDT 2001
On Tue, 22 May 2001, felix wrote:
> Using an expression over this xml:
>
> <Attribute Nasme="no">
> <value order='1' type='jpg'>mastercard</value>
> <value order='1' type='gif'>visa</value>
> <value order='2' type='gif'>unibank</value>
> </Attribute>
>
> How can I get the node <value order='1' type='gif'>visa</value>,
> because if I put the xpath expression /Attribute[@Nasme='no']/value[@order='1'], I get:
>
> <value order='1' type='jpg'>mastercard</value>
> <value order='1' type='gif'>visa</value>
>
> Thanks in advance
Well, it looks like you're getting back matching elements (they
both have order='1' attributes).
Just add another predicate...
/Attribute[@Nasme='no']/value[@order='1'][@type='gif']
If you know the image-type, or something.
If you want the second one, then add a proximity predicate:
/Attribute[@Nasme='no']/value[@order='1'][2]
Should work...
-bob
More information about the jdom-interest
mailing list