Skip to content

Instantly share code, notes, and snippets.

@starquake
Forked from frankhale/StripHtml.cs
Last active February 2, 2022 17:04
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save starquake/8d72f1e55c0176d8240ed336f92116e3 to your computer and use it in GitHub Desktop.
Save starquake/8d72f1e55c0176d8240ed336f92116e3 to your computer and use it in GitHub Desktop.
Strip HTML using HtmlAgilityPack
public static string StripHtml(this string value)
{
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(value);
if (htmlDoc == null)
return value;
return htmlDoc.DocumentNode.InnerText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment