搜索那些节点" col_functions"其表行值是" John Wayne"从表@class =" table_list"。
(" col_functions"," col_firstname"" col_lastname是表中的兄弟节点和子节点)
<table class="table_list">
<tbody>
<tr>
<td class="col_firstname">John</td>
<td class="col_lastname">Lennon</td>
<td class="col_functions"></td>
</tr>
<tr>
<td class="col_firstname">John</td>
<td class="col_lastname">Wayne</td>
<td class="col_functions"></td> <=== looking for this node!!
</tr>
<tr>
<td class="col_firstname">Wayne</td>
<td class="col_lastname">John</td>
<td class="col_functions"></td>
</tr>
</tbody>
<table>
答案 0 :(得分:1)
一种选择是检查整个地方的班级名称:
//table[@class="table_list"]//tr[td[@class="col_firstname"] = "John" and td[@class="col_lastname"] = "Wayne"]/td[@class="col_functions"]/text()
这里我们基本上检查table
内的所有行,查找姓名为John
且姓氏为Wayne
的单元格,并将col_functions
的单元格作为输出。
答案 1 :(得分:1)
使用兄弟姐妹会是这样的:
//table[@class='table_list']//td[@class='col_firstname'][text()='John']/following-sibling::td[@class='col_lastname'][text=()'Wayne']/following-sibling::td[@class='col_functions']