note 76376 added to ref.dom

From: Date: Thu, 12 Jul 2007 15:08:00 +0000
Subject: note 76376 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-128411@lists.php.net to get a copy of this message
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) ---- Server IP: 83.137.20.120 Probable Submitter: 84.29.41.89 ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- https://master.php.net/note/edit/76376 Del: integrated -- https://master.php.net/note/delete/76376/integrated Del: useless -- https://master.php.net/note/delete/76376/useless Del: bad code -- https://master.php.net/note/delete/76376/bad+code Del: spam -- https://master.php.net/note/delete/76376/spam Del: non-english -- https://master.php.net/note/delete/76376/non-english Del: in docs -- https://master.php.net/note/delete/76376/in+docs Del: other reasons-- https://master.php.net/note/delete/76376 Reject -- https://master.php.net/note/reject/76376 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128411) next »