2017-06-08 3 views
0

Ich habe eine Zeichenfolge (HTML) auf der Serverseite veröffentlicht und dann wird mit HTMLAgility-Pack validiert. Im HTML gibt es ein nicht geschlossenes Colgroup-Tag.HTMLAgility-Paket C# nicht geschlossene Colgroup-Tag

Nach Sterilisieren, der Schließen colgroup Tag erscheint aber direkt zwischen closing "tbody" und "table" Tag

VOR:

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

NACH:

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

Ich habe versucht, "OptionFixNestedTags" -Flag auf "True" zu setzen. Ich bekomme immer noch das gleiche Ergebnis.

Antwort

0

Ich habe verschiedene Optionen aus dem HTMLAgility-Paket ausprobiert und sie auf True gesetzt. Das hat nicht funktioniert.

OptionFixNestedTags = true; 
OptionAutoCloseOnEnd = true; 

Es gibt ein nettes Nuget-Paket, das den HTML-Code bereinigt. Das Problem, dem ich gegenüberstand, wurde hier angegangen ->HtmlSanitizer

Hoffe, das hilft.

Verwandte Themen