Possible Duplicate:
xpath select elements between two nodes
based on this html i need two xpath expressions:
<table dir = "rtl .......">
<tbody>
<script src = "get.aspx?type=js&file=ajax&rev=3"......>
<script language = "JavaScript" src = "get.aspx?type=js&file=mc&rev=6"></script>
<script>..</script>
<tr>
<td class = "d2"...>..</td>
</tr>
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <-- first expression should select these elements
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <--
<tr>
<td class = "d2"...>..</td>
</tr>
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <-- second expression should select these elements
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <--
<tr>..</tr> <--
</tbody>
how i can select all <tr> elements after the first <td class = "d2"...> tag with an xpath expression and all <tr> elements after the second <td class = "d2"...> tag with other xpath expression.
You can take the intersection of two node sequences in XPath 2.0 like so
In that expression, you will get all the tr siblings that follow the tr that contains the first td of class d2, and then remove those that are after the second such tr.
Unfortunately, XPath 1.0 does not have the concept of an intersection of two node sets. However, you can get the unions of two node sets in XPath 1.0 like so:
The following path will get you the tr nodes after the second tr that contains a td of class d2