首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

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

2012-02-14 
既要指定属性又要指定索引号这样xpath怎么写?如tabletrheight 30 td heightis30[1] /td/trt

既要指定属性又要指定索引号这样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 ");

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

热点排行