I created this based code, but how I remove all pre and code tags.
private static string RemoveHtmlTags(this string markup)
{
if (string.IsNullOrEmpty(markup))
{
return string.Empty;
}
var document = new HtmlDocument();
document.LoadHtml(markup);
return document.DocumentNode.InnerText;
}
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
doc.DocumentNode.Descendants()
.Where(n => n.Name == "script" || n.Name == "style")
.ToList()
.ForEach(n => n.Remove());
You can do so using HtmlDocument
class:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(input);
doc.DocumentNode.SelectNodes("//style|//script").ToList().ForEach(n => n.Remove());