Reputation: 2812
Let's say I want to find the <p>
tag that ONLY contains <u>***</u>
. What is the XPath query to use for this? I thought I found an answer in //p[u["..."]]
, but that does not work. This would be much easier if I could do something like //p[text()="<u>***</u>"]
.
Upvotes: 1
Views: 83
Reputation: 77
In your case, <u>
tag is child of <p>
, so you can use: "/..". This syntax can select parent node of current node. Your xpath should be:
//p/u[text()="<yourtext>"]/..
You should refer to XPath Toturial on w3school for more syntax of XPath.
Upvotes: 1