XPath query for contains() with multiple text elements
XPath query for contains() with multiple text elements
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.
//a[contains(text(),'world')]
This 'a' tag is kind of mix of text and another tag.
1 Answer
1
Try this one:
(//*[contains(., "world")])[last()]
or if you know for sure that it will be a
node:
a
//a[contains(.,'world')]
Also check the difference between string value and text node
Welcome. You can accept the answer if it solved your issue
– Andersson
Sep 11 '18 at 19:55
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thank you, that answers my question.
– user43103
Sep 11 '18 at 19:44