my input contain

<table border="0" align="center" width="100%">
<tr><td class="header">A
<td class="header">B
<td class="header"><b>C</b>
</tr>
</table>

the required output is

<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>

I tried the following reference

How to fix html tags(which is missing the <open> & <close> tags) with HTMLAgilityPack

the output i got

<table border="0" align="center" width="100%">
<tr><td class="header"></td>A
<td class="header"></td>B
<td class="header"></td><b>C</b>
</tr>
</table>

I am new to this HTML files...

Thanks in advance..

有帮助吗?

解决方案

The 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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top