What XPath selects the next <tr> after a <tr> containing X?

Viewed 52311
<tr>
 <td>Blah!</td>
 <td>X</td> <!-- TR containing X -->
 <td>Woot!</td>
</tr>
<tr>
 <td>Useful Data, contents unknown</td> <!-- Select this TR -->
</tr>
<tr>
 <td>Useless data</td> <!-- Don't select this or any subsequent TR -->
</tr>
<tr>
 <td>More crap I don't want</td>
</tr>
<tr>
 <td>X</td> <!-- Another X -->
</tr>
<tr>
 <td>Useful</td> <!-- Do select this one, since previous has X -->
</tr>

What XPath would return the <tr> immediately following the <tr> that contains X?

4 Answers

Use this for finding the next element from your element. Keep increasing for every hop:

//android.widget.TextView[contains(@text,'US Dollar')]/following::android.widget.TextView[1]
Related