我正在尝试使用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>
以下表达式正在here,here和here,但不在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有什么不同吗?