读书人

既要指定属性又要指定索引号这样xpath

发布时间: 2012-02-14 19:19:19 作者: rapoo

既要指定属性又要指定索引号这样xpath怎么写?

<table>
<tr height= "30 ">
<td> height is 30[1] </td>
</tr>
<tr height= "30 ">
<td> height is 30[2] </td>
</tr>
<tr height= "20 ">
<td> height is 20[1] </td>
</tr>
<tr height= "20 ">
<td> height is 20[2] </td>
</tr>
<tr height= "30 ">
<td> height is 30[3] </td>
</tr>
<tr height= "30 ">
<td> height is 30[4] </td>
</tr>
</table>

获取table中tr的height为30的第3项?
我这么写/table/tr[@height=30][3]/td不对,该怎么写呢?多谢了

[解决办法]
如果从XPATH的语法来说,写法没错。
但是前提是,你要用msxml2.domdocument.4.0或者以上版本。
3.0的版本必须指定查询语言,语句为:xml.setProperty( "SelectionLanguage ", "XPath ");

其他不指定具体版本的写法,没测试过,不作讨论。一般建议使用时指定具体版本。

读书人网 >XML SOAP

热点推荐