perfomance issues of dynamically removing node from document using c#

  • Thread starter Thread starter jambalapamba
  • Start date Start date
J

jambalapamba

I am removing node from a document depending on the style property and this is taking 5 seconds for checking complete document is there any ideas how can i improve the perfomance. Here is my part of code

foreach (IHTMLElement tempElement in document.all)
{
if (tempElement.style.visibility == "hidden" )
{

IHTMLDOMNode node = tempElement as IHTMLDOMNode;
node.parentNode.removeChild(node);

}
}

the for loop is taking more than 5 seconds for a page with size 100kb

From http://www.developmentnow.com/g/36_0_0_0_0_0/dotnet-languages-csharp.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 
Well, if the elements have no common attributes, then this is probably
the best that you can do.

If there is a way to narrow down the search, then you can call some
other methods on the IHTMLDocument3 interface to get subsets of all the
elements, namely, getElementsById, getElementsByName and
getElementsByTagName.
 
Back
Top