Neither XmlDocument nor HtmlDocument (from the HtmlAgilityPack library) want to work normally with the html page. Here is an example:

 HtmlDocument document = new HtmlDocument(); //document.Load(page); Console.WriteLine("checkpoint"); 

Everything is normal here. The console reads "checkpoint" quietly. But as soon as I uncomment document.Load(page); :

 HtmlDocument document = new HtmlDocument(); document.Load(page); Console.WriteLine("checkpoint"); 

nothing is output and in general, everything after document.Load(page); as if disappearing from the program. Why is this happening?

PS In my WPF application on windows, everything is working fine.

  • page what type of variable? - Eugene Krivenja
  • string . Contains all page code. - Puro

1 answer 1

If page is a line with a page code, then according to the documentation it is necessary to parse like this:

 // From String var doc = new HtmlDocument(); doc.LoadHtml(html); 

You are trying to feed the page code into a method that expects a file path in the string.