Alosyius
Alosyius

Reputation: 9121

c# htmlagilitypack xpath select all except with certain class

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."

Upvotes: 0

Views: 1684

Answers (1)

I4V
I4V

Reputation: 35353

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

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

Upvotes: 3

Related Questions