This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 18541
    
    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: 18541
    
    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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using AND operation in XPath
 
Similar Threads
Comparing only dates and not timestamp
If two different objects have same hashcode, how HashMap will retrieve these two objects?
How to use JSON & eval()
Why 100 * A * B * C is not same as A * B * C * 100 if A, B, C are double?
How to get a part of xml document in String format