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

SelectNodes() returns null

description

If there are no matches for a given XPath that is fed to SelectNodes() the result is null. Not only is this incorrect, but this forces us to have to check to see if the resulting collection is null before iterating over it.

If there are no matches, the collection should have ZERO nodes not NULL nodes. Zero and null are different concepts, and in this case, null is being used incorrectly and inconveniently.

comments

WardMD wrote Jan 15, 2016 at 6:38 PM

This one is pretty easy:

Comment out the following lines in HtmlNode.Xpath.cs (SelectNodes function):
        //if (list.Count == 0)
        //{
        //    return null;
        //}
Regards,
Mark Ward
Carson, CA

wrote Jan 15, 2016 at 6:39 PM

wrote Mar 4, 2016 at 10:11 AM

wrote Aug 31, 2016 at 9:23 AM