xpath表达式在HtmlAgilityPack上无法正常工作

时间:2015-02-07 21:45:48

标签: c# xpath html-agility-pack

我正在尝试使用xpath表达式搜索html节点 目标是匹配具有2个子tr个节点的所有td个节点,其属性为class="shiftHolder"(示例中为秒tr)。

<table>
       <tr class="staffRow">
          <td class="staff" data-staffid="2" data-primaryrole="1">
             <div class="sn">Leyla-claire Collins</div>
          </td>
          <td class="shiftHolder">
          </td>
          <td class="shiftHolder unavailable">
             Holiday
          </td>
       </tr>
       <tr class="staffRow">
          <td class="staff" data-staffid="11" data-primaryrole="4">
             <div class="sn">Natale Dersley</div>
          </td>
          <td class="shiftHolder">
          </td>
          <td class="shiftHolder">
          </td>
       </tr>
    </table>

以下表达式正在hereherehere,但不在HtmlAgilityPack上,两者都返回tr

//tr[@class='staffRow'][count(td[@class='shiftHolder'])=2][td[@class='staff' and @data-staffid and @data-primaryrole][div[@class='sn']]]

//tr[@class='staffRow' and count(td[@class='shiftHolder'])=2 and td[@class='staff' and @data-staffid and @data-primaryrole and div[@class='sn']]]

我不知道HtmlAgilityPack有什么不同吗?

0 个答案:

没有答案