Query XPath in Adobe CRX

444 views Asked by At

I am performing an XPath query in Adobe CRX and I am trying to find a list of nodes that contains the string 'Xbox Live'. What I am getting back are nodes that contain both 'Xbox' and 'Live'. I am wondering what would the query be to get an exact match of my string.

Current XPath Query: /jcr:root/content//*[jcr:contains(., 'Xbox Live')] order by @jcr:score

Example of content that I want returned:

  • This offer requires an Xbox Live account
  • Your Xbox Live user name is not valid
  • XBox Live is the future!

Example of content that I do not want returned:

  • Xbox and Playstation will live forever
  • Will I live longer then my Xbox?
  • The Xbox out lived my Wii
1

There are 1 answers

0
har07 On BEST ANSWER

Your xpath/xquery is fine, that should return elements containing exact phrase "Xbox Live", assuming Adobe CRX has decent xpath 1.0 implementation.

Possible catch is, by using . in contains() concatenation of all descendant text nodes will be evaluated. For example, the following parent element also considered matched the contains(., 'Xbox Live') predicate :

<parent>Xbox <child>Live</child></parent>

If you want to evaluate contains() to individual text nodes, and return parent element of matched text nodes, try the following instead :

/jcr:root/content//text()[jcr:contains(., 'Xbox Live')]/parent::* order by @jcr:score