HtmlAgilityPack: Get whole HTML document as string
C#Html Agility-PackC# Problem Overview
Does HtmlAgilityPack have the ability to return the whole HTML markup from an HtmlDocument object as a string?
C# Solutions
Solution 1 - C#
Sure, you can do like this:
HtmlDocument doc = new HtmlDocument();
// call one of the doc.LoadXXX() functions
Console.WriteLine(doc.DocumentNode.OuterHtml);
OuterHtml contains the whole html.
Solution 2 - C#
You can create WebRequest passing Url and Get webResponse . Get ResponseStream from WebResponse and read it into a String.
string result = string.Empty;
WebRequest req = WebRequest.Create(Url);
WebResponse res= wrq.GetResponse();
StreamReader reader = new StreamReader(res.GetResponseStream());
result = reader.ReadToEnd();
reader.Close();
res.Close();
Hope this helps.