如何根据两个属性的文本找到根节点

时间:2019-07-11 16:28:04

标签: xpath

我有一个动态Web表,我想根据两个不同文本属性的文本值选择节点。

//tr[.//td[contains(text(),'SATWIK GHANSIYAL')].//td[contains(text(),'07/07/2002')]]

HTML:

<html><head></head><body><table>
   <tbody><tr style="background-color:White;height:24px;">
    <td class="gridtext" align="center">
     <span class="checkboxclass"><input id="ctl00_ContentPlaceHolder1_grdUsers_ctl02_chkSelect" type="checkbox" name="ctl00$ContentPlaceHolder1$grdUsers$ctl02$chkSelect" onclick="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$grdUsers$ctl02$chkSelect\',\'\')',
     0)"></span>
                                                                         
                                                                                                                                              </td><td class="gridtext" align="left" style="background-color:#FDE9D9;">SATWIK GHANSIYAL</td>
    
     <td class="gridtext" align="left" style="background-color:#FDE9D9;" xpath="1">RAJESH GHANSIYAL</td>
    
    <td class="gridtext" align="left" style="background-color:#FDE9D9;">SHELLY</td>
    
     <td class="gridtext" align="left" style="background-color:#FDE9D9;">07/07/2002</td>
	 </tr>
	 </tbody></table>
</body></html>

我没有找到按摩内容

1 个答案:

答案 0 :(得分:0)

使用它。

//tr[.//td[contains(.,'SATWIK GHANSIYAL')] and .//td[contains(.,'07/07/2002')]]

尝试根据给定的xml评估此表达式

//tr[.//td[contains(text(),'SATWIK GHANSIYAL')] and .//td[contains(text(),'07/07/2002')]]

text()返回多个序列,因此给了我这个错误消息。

Unable to perform XPath operation. A sequence of more than one item is not allowed as the first argument of contains() ("", "")