<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: DOMNodeList Gotchas</title>
	<link>http://robrosenbaum.com/php/domnodelist-gotchas/</link>
	<description>PHP, Symfony, and Other Web Things</description>
	<pubDate>Tue, 02 Dec 2008 03:12:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: Stuart Laverick</title>
		<link>http://robrosenbaum.com/php/domnodelist-gotchas/#comment-10</link>
		<dc:creator>Stuart Laverick</dc:creator>
		<pubDate>Thu, 16 Aug 2007 08:46:19 +0000</pubDate>
		<guid>http://robrosenbaum.com/php/domnodelist-gotchas/#comment-10</guid>
		<description>Thanks Rob, I've been banging my head against a wall due to this 'feature' for half a day.
I'm writing a site creation app for a hosting and internet directory company. The app uses a lot of dom and xml technology, and implements content creation methods as page objects (ie objects used by the page). To provide future proofing, each object first loads it's default parameters then overwrites them with the current parameters, this allows new parameters to be easily added.
The parameter lists (both default and current)are provided as dom objects, from which domNodeLists are created, these are then iterated over, replacing default with current using replaceChild().
I could not figure why I kept getting script timeouts, and if I dumped the activity of the routine, it was just accessing the first parameter over and over again. This truly drove me nuts!
Then after reading your article, I realised that as I was using a foreach to iterate the domNodeList, and as on each pass the list was being recreated, the foreach would see this as a new collection and reset the pointer.
Interestingly I should have known this as the same behaviour is well known in javascript dom manipulation, where any change to the dom will cause the dom to be recreated.
This definitely needs noting on the php site under the replaceChild function. Let me know if you are too busy to do this and I will add an entry, if not I recommend you add a note to the page.
Thanks.</description>
		<content:encoded><![CDATA[<p>Thanks Rob, I&#039;ve been banging my head against a wall due to this &#039;feature&#039; for half a day.<br />
I&#039;m writing a site creation app for a hosting and internet directory company. The app uses a lot of dom and xml technology, and implements content creation methods as page objects (ie objects used by the page). To provide future proofing, each object first loads it&#039;s default parameters then overwrites them with the current parameters, this allows new parameters to be easily added.<br />
The parameter lists (both default and current)are provided as dom objects, from which domNodeLists are created, these are then iterated over, replacing default with current using replaceChild().<br />
I could not figure why I kept getting script timeouts, and if I dumped the activity of the routine, it was just accessing the first parameter over and over again. This truly drove me nuts!<br />
Then after reading your article, I realised that as I was using a foreach to iterate the domNodeList, and as on each pass the list was being recreated, the foreach would see this as a new collection and reset the pointer.<br />
Interestingly I should have known this as the same behaviour is well known in javascript dom manipulation, where any change to the dom will cause the dom to be recreated.<br />
This definitely needs noting on the php site under the replaceChild function. Let me know if you are too busy to do this and I will add an entry, if not I recommend you add a note to the page.<br />
Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
