2017-06-08 2 views
0

J'ai une chaîne (HTML) en cours de publication sur le serveur, puis elle est validée à l'aide de HTMLAgility pack. Dans le code HTML, il existe un tag colgroup non fermé.HTMLAgility pack C# étiquette colgroup non fermée

Après avoir désinfecté, la balise colgroup de fermeture apparaît, mais juste entre la fermeture "tbody" et tag "table"

AVANT:

<table width="3265" class="mce-item-table" style="width: 2452pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"> 
 

 
<colgroup><col width="80" style="width: 60pt;"> 
 
<col width="245" style="width: 184pt;" span="13"> <!-- MISSING COLGROUP tag--> 
 
<tbody><tr height="20" style="height: 15pt;"> 
 
    <td width="80" height="20" style="width: 60pt; height: 15pt; color: blue; text-decoration: underline; text-underline-style: single;"><span style="color: blue;">31109173</span></td> 
 
    <td width="245" style="width: 184pt; font-family: Arial; font-size: 9pt;">31109173</td> 
 
    <td width="245" align="right" style="width: 184pt; font-family: Arial; font-size: 9pt;">May 09,2017 9:54 AM</td> 
 
    <td width="245" align="right" style="width: 184pt; font-family: Arial; font-size: 9pt;">May 08,2017 5:21 PM</td> 
 
</tr> 
 
<tr height="20" style="height: 15pt;"> 
 
    <td height="20" style="height: 15pt; color: blue; text-decoration: underline; text-underline-style: single;"><span style="color: blue;">30933775</span></td> 
 
    <td style="font-family: Arial; font-size: 9pt;">30933775</td> 
 
    <td align="right" style="font-family: Arial; font-size: 9pt;">May 09,2017 9:50 AM</td> 
 
    <td align="right" style="font-family: Arial; font-size: 9pt;">Apr 28,2017 6:22 PM</td> 
 
</tr> 
 
</tbody></table>

APRÈS:

<table width="3265" class="mce-item-table" style="width: 2452pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"> 
 

 
<colgroup><col width="80" style="width: 60pt;"> 
 
<col width="245" style="width: 184pt;" span="13"> 
 
<tbody><tr height="20" style="height: 15pt;"> 
 
    <td width="80" height="20" style="width: 60pt; height: 15pt; color: blue; text-decoration: underline; text-underline-style: single;"><span style="color: blue;">31109173</span></td> 
 
    <td width="245" style="width: 184pt; font-family: Arial; font-size: 9pt;">31109173</td> 
 
    <td width="245" align="right" style="width: 184pt; font-family: Arial; font-size: 9pt;">May 09,2017 9:54 AM</td> 
 
    <td width="245" align="right" style="width: 184pt; font-family: Arial; font-size: 9pt;">May 08,2017 5:21 PM</td> 
 
</tr> 
 
<tr height="20" style="height: 15pt;"> 
 
    <td height="20" style="height: 15pt; color: blue; text-decoration: underline; text-underline-style: single;"><span style="color: blue;">30933775</span></td> 
 
    <td style="font-family: Arial; font-size: 9pt;">30933775</td> 
 
    <td align="right" style="font-family: Arial; font-size: 9pt;">May 09,2017 9:50 AM</td> 
 
    <td align="right" style="font-family: Arial; font-size: 9pt;">Apr 28,2017 6:22 PM</td> 
 
</tr> 
 
</tbody></colgroup></table> 
 

 
<!-- ^^ </colgroup> has appeared above-->

J'ai essayé de définir l'indicateur "OptionFixNestedTags" sur true. Je reçois toujours le même résultat.

Répondre

0

J'ai essayé différentes options du pack HTMLAgility et les ai définies. Cela n'a pas fonctionné.

OptionFixNestedTags = true; 
OptionAutoCloseOnEnd = true; 

Il existe un joli paquet Nuget qui assainit le code HTML. Le problème que j'ai rencontré a été abordé ici ->HtmlSanitizer

Espérons que cela aide.