Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ryancole
Created June 11, 2015 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryancole/8c85c725f600766cec73 to your computer and use it in GitHub Desktop.
Save ryancole/8c85c725f600766cec73 to your computer and use it in GitHub Desktop.
var html = new HtmlDocument();
// load the document's html
html.LoadHtml(document.Html);
// create a string of the text only
document.Text = Regex.Replace(string.Join(" ", html.DocumentNode.SelectNodes("//text()").Select(m => m.InnerText)), @"\s+", " ").Trim();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment