Build HTMLDocument from string of HTML

.net c# dom html-agility-pack

Question

I would like to build a HTMLDocument from a string of HTML.

I already have a large amount of code that parses and uses the HTMLDocument, so I don't want to turn back now. But now I've gone back and used HTMLAgilityPack to get the HTML instead of a WebBrowser (because you can't open a page and load the document in another Thread since the WebBrowser locks up my application. So I switched to the agility pack). So I would like to build a regular System.Forms.HTMLDocument using the string of HTML that I obtained using the HTMLAgilityPack.

Is there a way to build a System.Forms.HtmlDocument from a string of HTML?

Popular Answer

How about using HtmlDocument.Write() method this way :

HtmlDocument doc = webBrowser1.Document.OpenNew(true);
doc.Write("put html string from HTMLAgilityPack here");

HtmlDocument doesn't expose public constructor, it is embedded in WebBrowser. So, you'll still need to have a WebBrowser control.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why