c# htmlagilitypack xpath select all except with certain class

我的未来我决定 提交于 2019-12-14 03:12:31

问题


I am trying to select all li tags on a page that do not have the class="r"

What i have so far is:

.//li

This is what ive tried so far

//li[not([@class='r'])]

With that i get the error:

"Expression must evaluate to a node-set."


回答1:


use this expression //li[not(@class='r')]

var lis = htmlDoc.DocumentNode.SelectNodes("//li[not(@class='r')]")


来源:https://stackoverflow.com/questions/16649928/c-sharp-htmlagilitypack-xpath-select-all-except-with-certain-class

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