C# HTMLAgilityPack Select not contains

c# console html-agility-pack xpath

Question

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

Popular Answer

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.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why