public static void Main()
.Load("http://stackoverflow.com/questions/30926684")
.SelectSingleNode("//td[@class='postcell']//div[@class='post-text']");
Console.WriteLine(html.InnerHtml);
Console.WriteLine("\n********************************************************\n");
Console.WriteLine(Truncate(html, 1000));
private static void RemoveEmpty(HtmlNode node)
var parent = node.ParentNode;
if(!parent.Descendants().Any())
private static string Truncate(HtmlNode root, int limit)
foreach(var node in root.Descendants().OfType<HtmlTextNode>().ToArray())
int length = node.Text.Length;
if (currentLength > limit)
return root.CloneNode(true).InnerHtml;