0

Having the following markup:

<p>
  <span>text</span>
  foo
</p>
<p>
  <span>text</span>
  bar
</p>
<p>
  <span>text</span>
  baz
</p>

how can I select the second node based on the bar text using xpath?

Note that I do not want to select the text as it is discussed here: XPath - how to select text

what I need, is to select the parent node based on the containing text node.

kongeor
  • 712
  • 1
  • 6
  • 14

1 Answers1

0

Have you tried

//p[text()[normalize-space(.)='bar']]

Pankaj Jaju
  • 5,371
  • 2
  • 25
  • 41