This project has moved and is read-only. For the latest updates, please go here.

HtmlNode.SelectNodes behaves strangely with "//..." selector


I'd expect node.SelectNodes("//div") to return all divs that are descendents of node. Instead, it returns all divs in the document. It is behaving as if node == document.DocumentNode.
            var doc = new HtmlDocument();
            doc.LoadHtml("<div class=\"a\"><div class=\"b\"></div></div>");
            var outer = doc.DocumentNode.SelectSingleNode("/div");
            var inner1 = outer.SelectNodes("/div");
            var inner2 = outer.SelectNodes("//div");
            Debug.Assert(inner2.Count == 1); //fails
XElement XPath queries behave differently:
XElement root = new XElement("div",
    new XElement("div"
var el = root.XPathSelectElement("/div").XPathSelectElements("//div");
Execute this in LINQPad to see that only one div was output.

So it looks like this is a bug. If not, it's not useful behavior.