• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using AND operation in XPath

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic