user3091209
user3091209

Reputation: 81

C# HTMLAgilityPack Select not contains

My program is a simple c# console application, I am unsure of howto achieve my goal, basically I am selecting a single node but I would like to ignore an tag with a particular text value, my code is below.

string name = item.SelectSingleNode("//select[contains(@id,'var')]//option")
                  .GetInnerTextFromNode();

I know in jQuery you could use :not filter, but not sure in C# and I have search for documentation for the pack, but nothing has surfaced.

Thank you

Upvotes: 2

Views: 3323

Answers (1)

jessehouwing
jessehouwing

Reputation: 115017

Simply taking RGraham's comment and turning it into an answer:

 string name = item.SelectSingleNode("//select[not(contains(@id,'var'))]//option")
              .GetInnerTextFromNode();

As for guidance on what kind of functions you can use, check out the w3schools XPath tutorials.

Upvotes: 3

Related Questions