Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Using AND operation in XPath

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • 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: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
ice is for people that are not already cool. Chill with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic