perfomance issues of dynamically removing node from document using c#

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top