Description: To
Remove unwanted Script 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 script tags in html document is as given below.
public static HtmlDocument RemoveScripts(HtmlDocument objHTMLdoc)
{
HtmlNodeCollection
nodes = objHTMLdoc.DocumentNode.SelectNodes("//script");
if
(nodes != null)
{
for
(int Index = 0; Index < nodes.Count();
Index++)
{
HtmlNode
node = nodes[Index];
node.Remove();
}
}
return
objHTMLdoc;
}
No comments:
Post a Comment