Mark Gargan
Mark Gargan

Reputation: 863

Chaining xpath axes

<tr class="even">
<td>101</td>
<td>NotProvisioned</td>
<td>1</td>
<td>
    <a href="procdef.jsf?id=101">Examine</a>
</td>

Hi folks, I've a number rows in a table. Using xpath I need to select the element in the row where one of the td cells has the text value NotProvisioned and one of it's siblings has a

In firebug I tried the following,

$x("//td[[contains(text(),'NotProvisioned')]/following-sibling::* and child:a[contains(text(),'Examine']]")

I'm not sure if I'm even rooting on the right element. I should looking for an a element who's text is 'Examine' and whom has a preceding-ancester who's text is NonProvisioned but I can't figure out how to chain accordingly.

Any help would greatly appreciated.

thanks, Mark.

Upvotes: 0

Views: 1759

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167716

If you use //td[preceding-sibling::td[. = 'NotProvisioned']]/a[. = 'Examine'] you select a element children of td elements where the string value of the a element is Examine and the td has a preceding sibling td that has the string value NotProvisioned. If the a element can be a descendant you can use //td[preceding-sibling::td[. = 'NotProvisioned']]//a[. = 'Examine'] instead.

Upvotes: 1

Related Questions