2
对HtmlAgilityPack处理已经生成的表格行而不使用name
或id
。相反,我需要根据包含在该行的bgcolor属性的值来选择:我明白了XPath将返回在name
属性= display
所有行与TR元素的bgcolor属性相匹配的XPath表达式
:
foreach(HtmlNode cell in doc.DocumentElement.SelectNodes("//tr[@name='display']/td")
考虑下面的代码片段,是什么表达式将选择所有元素当行的bgcolor ="#FFFFFF"
>?
我已经试过:SelectNodes(//tr[@bgcolor='#FFFFFF']/td")
> <tr bgcolor="#EAF2FA">
> <td colspan="2">
> <font style="font-family: sans-serif; font-size:12px;"><strong>Name</strong></font>
> </td> </tr> <tr bgcolor="#FFFFFF">
> <td width="20"> </td>
> <td>
> <font style="font-family: sans-serif; font-size:12px;">Steve</font>
> </td> </tr>
THX
中的XPath对我来说比赛就好了。我看不出为什么它不应该工作。你能展示更多的代码吗? – shriek
我发现我的代码_does匹配,当我使用完全形成的HTML文档。谢谢你指出我工作的方向是正确的。 – justSteve