Q:

determine if div class exists?

in c#.net using htmlagilitypack, how would I determine if "test3" exists/is there?
i am accessing each article using a foreach loop with a HTMLNode defintion for each element that exists.
I tried
if (node.descendants("div") == true)... but this wouldn't work

A:

You can use XPath.
bool exist = doc.DocumentNode.SelectSingleNode("//div[@class='test3']") != null;

It would be much simpler than linq version
bool exist = doc.DocumentNode.Descendants("div")
                .Any(div => div.Attributes["class"] != null && 
                            div.Attributes["class"].Value == "test3");

