Description: To
Remove unwanted Style tags, we need to search them using HtmlAgility Filter and
then need to use remove function of node to delete them.
Customized method to delete all style tags in html
document is as given below.
public static HtmlDocument removeUnwantedStyles(HtmlDocument doc)
{
int
mStyleIndex = 0;
try
{
HtmlNodeCollection
nc = doc.DocumentNode.SelectNodes("//style");
if
(nc != null)
{
for
(mStyleIndex = 0; mStyleIndex < nc.Count(); mStyleIndex++)
{
HtmlNode node = nc[mStyleIndex];
node.Remove();
}
}
}
catch
(Exception ex)
{
throw
ex;
}
return
doc;
}
No comments:
Post a Comment