使用htmlagilitypack搜索具有特定属性的节点 [英] Search for nodes having a certain attribute with htmlagilitypack

查看:286
本文介绍了使用htmlagilitypack搜索具有特定属性的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仅看到了有关如何搜索属性具有或包含某些值的节点的示例,但找不到用于搜索属性存在的节点的示例.

I have only seen examples on how to search for nodes where attributes have or contain certain values but I cannot find one where you search for nodes where the attribute exists to start with.

那是怎么做的?

推荐答案

您可以尝试将其循环:

HtmlAgilityPack.HtmlDocument doc = htmlWeb.Load("somewebsite.org");    
foreach(HtmlNode matchedNode in doc.DocumentNode.SelectNodes("//*[@attrX]") {
    /* ... */
} 

这篇关于使用htmlagilitypack搜索具有特定属性的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆