How to use xpath to get all the <tr>
s which contains <a>
with href containing string "xxx"?
.......
<tr><td>...</td><td><a href="xxx3" /a></td><td>...</td>......</tr> <!-- yes -->
<tr><td>...</td><td>...</td><td><a href="ab_xxx" /a></td>......</tr> <!-- yes -->
<tr><td>...</td><td>...</td><td>...</td>......</tr> <!-- no-->
.....
Try the xpath:
A couple of notes:
.//a
instead of//a
(note the starting period). The period says to look anywhere within the current node (ie the tr). Without the period, it looks for the anchor to be present anywhere in the document.contains
method is used to check if the href attribute includes the string.