C#C
C#2y ago
Akex

Object reference not set to an instance of an object.

root is an HtmlNode but when I try to access anything using SelectSingleNode or SelectNodes it will raise this error when trying to access any methods of them.

HtmlDocument doc = new();
doc.LoadHtml($"{url}/page/{page}/");

HtmlNode root = doc.DocumentNode;
Console.WriteLine(root.GetType());
Console.WriteLine(root.SelectSingleNode("//div").GetType());
Was this page helpful?