2017-06-08 8 views
0

文字列(HTML)がサーバー側に送信され、HTMLAgilityパックを使用して検証されています。 HTMLには、閉じられていないcolgroupタグがあります。HTMLAgilityパックC#非公開colgroupタグ

消毒した後、クロージングCOLGROUPタグが表示されますが、右のクロージング "TBODY" と "テーブル" タグの間

、BEFORE:

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

AFTER:

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

"OptionFixNestedTags"フラグをtrueに設定しようとしました。私はまだ同じ結果を得る。

答えて

0

HTMLAgilityパックからさまざまなオプションを試してみました。これはうまくいかなかった。

OptionFixNestedTags = true; 
OptionAutoCloseOnEnd = true; 

HTMLをサニタイズ素敵Nugetパッケージがあります。私が直面した問題は、ここで取り組んでいた - >HtmlSanitizer

希望これは役立ちます。

関連する問題