WebBrowser - HtmlDocument

Topics: Developer Forum, Project Management Forum, User Forum
Dec 25, 2009 at 3:51 PM
Edited Dec 25, 2009 at 3:53 PM

Does anyone know how to solve this problem below?


HtmlAgilityPack.HtmlDocument doc;
doc = webBrowser1.Document;

It gives me this error:

Cannot implicitly convert type "System.Windows.Forms.HtmlDocument" to 'HtmlAgilityPack.HtmlDocument'

I want to parse html from a webbrowser.


Dec 25, 2009 at 4:59 PM

the webbrowser controls Document property is not an HtmlAgilityPack HtmlDocument object, it is an HtmlDocument object that belongs to System.Window.Forms . Other than their name, they have no relation to each other.


Dec 27, 2009 at 10:26 AM

You should try this instead

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

Note: this could be added as a cast operator to the Html Agility Pack HtmlDocument class so your original code would compile as is...