Fix missing HTML Tags using htmlagility pack
See the question and my original answer on StackOverflowThe Html Agility Pack has a special option available as a property on the HtmlDocument
class, named OptionFixNestedTags
for fixing this kind of HTML errors:
static void Main(string[] args)
{
HtmlDocument doc = new HtmlDocument();
doc.OptionFixNestedTags = true;
doc.Load(YourFile);
doc.Save(Console.Out);
}
This will output:
<table border="0" align="center" width="100%">
<tr><td class="header">A
</td><td class="header">B
</td><td class="header"><b>C</b>
</td></tr>
</table>