HtmlDocument doc = new HtmlDocument();
doc.Load(yourhtml);
doc.Save(Console.Out);
How to save this into an string instead of Console.Out
HtmlDocument doc = new HtmlDocument();
doc.Load(yourhtml);
doc.Save(Console.Out);
How to save this into an string instead of Console.Out
string s = doc.DocumentNode.OuterHtml;
or
var sw = new StringWriter();
doc.Save(sw);
var s = sw.ToString();
string variableName = doc.DocumentNode.OuterHtml;
OuterHTML will have the Entire HTML..
string s = doc.DocumentNode.OuterHtml
Why not using this:
var str = File.ReadAllText(yourHtml);
It will read your html document to string without initializing HtmlDocument object. Is yourHtml
really a html or just a path? HtmlAgilityPack.HtmlDocument does not contain Load method accepting html.
HtmlDocument doc = new HtmlDocument();
// call one of the doc.LoadXXX() functions
Console.WriteLine(doc.DocumentNode.OuterHtml);