note 76376 deleted from ref.dom by nlopess

From: Date: Fri, 13 Jul 2007 19:27:26 +0000
Subject: note 76376 deleted from ref.dom by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128502@lists.php.net to get a copy of this message
Note Submitter: Merijn van den Kroonenberg ---- When working with a long DOMNodeList, then iterating this nodelist can be *VERY* slow. For example I had a XML document with 120,000 elements. I used getElementsByTagName() to get all elements with a specific name, which resulted in a nodelist with 100,000 elements. When itereating this list, the first elements could be retrieved very fast, but the further down the list, the slower each element was retrieved. I used a foreach loop on the nodelist. The slowdown was a matter of magnitudes. After this I just iterated all elements with $element->nextSibling and this was much faster, even for elements at the start of the list. Offcource, this is more work to implement if your structure of elements is not so simple as in my case. Merijn (Contact: http://www.web2all.nl/contact_formulier.php)

« previous php.notes (#128502) next »