HtmlAgilityPack DocumentNode.SelectNodes返回null,不应该

我正在尝试使用HTML敏捷包从示例页面中删除内容。 当我认为它不应该时,DocumentNode.SelectNodes为XPath查询返回null。 有人能告诉我为什么吗? 代码是:

HtmlDocument doc = new HtmlDocument(); string xpath = "//h1[@class='product-title fn']"; // note, it still returns // null even with "//div" doc.OptionFixNestedTags = true; HtmlNode.ElementsFlags.Remove("form"); HtmlNode.ElementsFlags.Remove("option"); HtmlNodeCollection coll = doc.DocumentNode.SelectNodes(xpath); if (coll != null) { // do stuff } else { // not expecting it to be null unless no matches } 

根据上游bug评论,它是为了保持一致性:

DarthObiwan于2011年1月11日下午9:27写道

之前已经介绍过,编写此函数是为了模仿System.XML的工作方式。 这样做会导致重大的突破性变化,因此可能会定为2.0