dimanche 31 août 2014

HtmlAgilityPack - Getting rid of Ads between html comment tags


Vote count:

0




I need to get rid of the Part between <!-- custom ads -->and <!-- /custom ads --> in this code snippet.



<!-- custom ads -->
<div style="float:left">
<!-- custom_Forum_Postbit_336x280 -->
<div id='div-gpt-ad-1526374586789-2' style='width:336px; height:280px;'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1526374586789-2');
</script>
</div>
</div>
<div style="float:left; padding-left:20px">
<!-- custom_Forum_Postbit_336x280_r -->
<div id='div-gpt-ad-1526374586789-3' style='width:336px; height:280px;'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1526374586789-3');
</script>
</div>
</div>
<div class="clear"></div>

<br>
<!-- /custom ads -->


<!-- google_ad_section_start -->Some Text,<br>
Some More Text...<br>
<!-- google_ad_section_end -->


I can already find the two comments with this xPath //comment()[contains(., 'custom')], but now i'm stuck with how to remove everything, which is in between those "tags".



foreach (var comment in htmlDoc.DocumentNode.SelectNodes("//comment()[contains(., 'custom')]"))
{
MessageBox.Show(comment.OuterHtml);
}


Any suggestions?



asked 1 min ago







HtmlAgilityPack - Getting rid of Ads between html comment tags

Aucun commentaire:

Enregistrer un commentaire