Then use the LINQ interfaces of Descendants and Elements.
SelectNodes matches the .NET System.Xml API for which it was built upon.
I agree this should be overhauled to return an empty list but the fact is there are thousands of applications out there that could break if this is changed in a minor point release. There were new LINQ like functions added of Descendants, Elements and DescendantNodes
to more closely match the LINQ to XML interface.
This is one of the things I wanted to address in 2.0 if I can ever get the time to work on it. The actual current implementation with HtmlNodeCollection needs to be tossed out and replaced with a yield return and an IEnumerable<HtmlNode> return type;
For the people that want this, an extension method can solve it
public static IList<HtmlNode> SelectNodesAsList(this HtmlNode node, string xpath)
var list = node.SelectNodes(xpath);
if (list == null)
return new List<HtmlNode>();