wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Using AND operation in XPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Using AND operation in XPath" Watch "Using AND operation in XPath" New topic
Author

Using AND operation in XPath

H Melua
Ranch Hand

Joined: Jan 04, 2005
Posts: 172
Hello

Assuming that I've got this XML File


and I want to search for all elements that contain particular <a> and <b> values... how do I do that in xpath? This for example checks each value seperately and returns the 2 sets of <a> and <b>...



but rather than the SET operator I want the AND, so it should only return the nodes that contain both values...

can someone advice me on how to tackle this?

I tried this but it didnt work


Thanks
HannaH
[ November 04, 2007: Message edited by: H Melua ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You want "the elements for which a is something and b is something else", right? So that'sIf you say out loud what you want, usually you will find the XPath is very similar to what you said.
[ November 04, 2007: Message edited by: Paul Clapham ]
H Melua
Ranch Hand

Joined: Jan 04, 2005
Posts: 172
thanks but no
I've tried this before and it didnt work , it says



could the problem be that Jaxon 1.1.1 does not yet support the AND operation?!!
[ November 05, 2007: Message edited by: H Melua ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I have never heard of Jaxon, but if it doesn't support basic features of XPath then it's not worth using. I notice in the XPath Recommendation that they use "and" for "and". You could try that instead of "AND".
H Melua
Ranch Hand

Joined: Jan 04, 2005
Posts: 172
thank youuuuuuuuu soooooooooooo much

ohhh life rescuer

dont I just love this place

(I turned on smilies so this post could have its full meaning - PC)
[ November 05, 2007: Message edited by: Paul Clapham ]
 
GeeCON Prague 2014
 
subject: Using AND operation in XPath