Search for nodes having a certain attribute with htmlagilitypack

拟墨画扇 提交于 2019-12-11 13:59:31

问题


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.

How is that done?


回答1:


You could try to just loop over it :

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


来源:https://stackoverflow.com/questions/22933368/search-for-nodes-having-a-certain-attribute-with-htmlagilitypack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!