HtmlAgilityPack: Get whole HTML document as string
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.
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.
First, install the HTMLAgilityPack nuget package into your project. Then, as an example: HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); // There are various options, set as needed htmlDoc.OptionFixNestedTags=true; // filePath is a path to a file containing the html htmlDoc.Load(filePath); // Use: htmlDoc.LoadHtml(xmlString); to load from a string (was htmlDoc.LoadXML(xmlString) // ParseErrors is an ArrayList containing … Read more