xpath - xpath:在html表行中搜索节点(多个条件)

标签 xpath parent nodes siblings

寻找一个xpath节点,其表行必须满足多个条件

从表@ class =“ table_list”中搜索表行值为“ John Wayne”的那些节点“ col_functions”。

(“ 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>

最佳答案

一种选择是在各处检查类名:

//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作为单元格的输出。

关于xpath - xpath:在html表行中搜索节点(多个条件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25765603/

相关文章:

javascript - 在jquery中查找远方 parent

c++ - 如何删除特定节点是二叉搜索树?

C - 删除链表中的节点

sql - XQuery [nodes()] : Syntax error near '<eof>' , 需要一个步骤表达式

XPath 将元素中的所有文本作为一个值获取,删除换行符

xml - 搜索XML以字符开头的属性

jquery - 使用 JQuery 从父级滚动 iframe

php - 如何使用 xPath 知道节点是否是 XML 中的结束标记 </>?

angularjs - Angular TreeView -获取父节点

java - 如何在链表的节点上插入数组