Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search using XPath

 
H Melua
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'd like to know how to search for a particular word in a child element.. like searching for the word "happy" in

<word>i'm feeling happy<word>

I can search for the whole sentence, and i can check using "contains" function that the word actually exists there, but i want it to return the element not just returns true!

any ideas?

thanks :thumb:
HannaH
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want elements where the text contains "happy"? When your requirements contain that word "where", that means you should use a predicate. So your XPath would look like this:
word[contains(*,'happy')]
 
H Melua
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but that doesnt seem to return anything at all

i've tried doing this..



but that didnt work either , when i check the list returned from this query, it tell me that the size of the list is 3 (which is right) but when i try to extract the word element using



it returns null
 
Craig Bayley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Evaluating XPath:

gives 'i'm feeling happy'
 
H Melua
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much guys

I guess the problem is somewhere else

-----------------------------------

EDITED!!!

now it works!!! bloody hell, it took me weeks to figure out why it wasnt doing it!! i had to demonstrate 2 of my assignments without making my lecturer realise that the search wasnt working correctly!

oh well, now it does

Thanks very much again :thumb:
[ November 27, 2007: Message edited by: H Melua ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic