1

How can I find all tags that have text "world"?

<c>
    <a>
        <b>hello</b>
        world
    </a>
</c>

Expected result should be tag 'a'. I am trying //a[contains(text(),'world')] but it doesn't give anything.

This 'a' tag is kind of mix of text and another tag.

user43103
  • 41
  • 1
  • 6

1 Answers1

0

Try this one:

(//*[contains(., "world")])[last()]

or if you know for sure that it will be a node:

//a[contains(.,'world')]

Also check the difference between string value and text node

Andersson
  • 51,635
  • 17
  • 77
  • 129