XPATH Query: How to get two elements?
Posted
by Damiano
on Stack Overflow
See other posts from Stack Overflow
or by Damiano
Published on 2010-05-08T10:32:48Z
Indexed on
2010/05/08
10:38 UTC
Read the original article
Hit count: 322
Hello
My HTML code is:
<table>
<tr>
<td class="data1"><p>1</td></td>
<td class="data1"><p>2</td></td>
<td class="data1"><p>3</td></td>
<td class="data1"><p>4</td></td>
</tr>
<tr>
<td class="data1"><p>5</td></td>
<td class="data1"><p>6</td></td>
<td class="data1"><p>7</td></td>
<td class="data1"><p>8</td></td>
</tr>
</table>
My query is:
xpath='//tr//td[@class="data1"][4]/p'
The results is:
<p>4</p>
<p>8</p>
The results is correct! but, if I want to get example:
<p>3</p> <p>4</p>
<p>7</p> <p>8</p>
So
[3]/p and [4]/p
How to get these two elements each <tr>
?
Thank you so much!
© Stack Overflow or respective owner