我想解析特定的表以进行报废。表的代码如下:
<table class="NormalText" cellspacing="1" cellpadding="2" width="100%" border="0"
bgcolor="#eeeeee">
<tr>
<td width="108" align="center">
Stock No.
</td>
<td width="108" align="center">
<span id="invModule_grid_row18_lblMileage">Mileage</span>
</td>
<td width="108" align="center">
Color
</td>
<td width="76" align="center">
Interior
</td>
<td width="104" align="center">
Transmission
</td>
<td width="110" align="center">
Engine
</td>
</tr>
<tr>
<td width="108" align="center">
1204
</td>
<td width="108" align="center">
161,328
</td>
<td width="108" align="center">
Tan
</td>
<td width="76" align="center">
Leather
</td>
<td width="104" align="center">
Automatic
</td>
<td width="110" align="center">
3.5L V6 DOHC 16V
</td>
</tr>
<tr>
<td colspan="7" height="7">
</td>
</tr>
</table>
我想要的输出是
1194 56,200 Blue Vinyl 5 Speed 6.8L V10 SOHC 30V
问题
答案 0 :(得分:2)
以下示例选择表中表行中所有td节点的文本:
//table/tr[position()>1]/td/text()
获取最后一个表:
//table[last()]/tr[position()>1]/td/text()
获取第三个表:
//table[2]/tr[position()>1]/td/text()
获取基于属性的表,在本例中为class =“NormalText”:
//table[@class='NormalText']/tr[position()>1]/td/text()