The solution to this the following:
var doc = new HtmlDocument();
HtmlNode.ElementsFlags["br"] = HtmlElementFlag.Empty;
doc.OptionWriteEmptyNodes = true;
doc.LoadHtml(html);
//process data
return doc.DocumentNode.OuterHtml;
More can be found on this StackOverflow post
2 comments:
Thanks that helped me a lot!!
It happens because the Html Agility Pack handles the BR in a special way. It still supports old (but existing on the web today) HTML 3.2 syntax where the BR could be declared without a closing tag at all (browsers also still handle it gracefully by the way...).
psdtohtmlpro.com
Post a Comment