]> git.sesse.net Git - xml-template/commitdiff
Fix a bug where a cleaning run could skip over certain nodes under PHP5.
authorsgunderson@bigfoot.com <>
Sat, 26 Apr 2008 17:15:53 +0000 (19:15 +0200)
committersgunderson@bigfoot.com <>
Sat, 26 Apr 2008 17:15:53 +0000 (19:15 +0200)
php5/xml-template.php

index ed1e8f85529fc389120184c8023dee97a516518a..8e53452675bae110183ccc9c53ab09befc2d9a5d 100644 (file)
@@ -32,8 +32,13 @@ function XML_Template_process($node, $obj, $clean = 1)
                $node->appendChild($doc->createTextNode($obj));
        } else if (is_associative_array($obj)) {              # substitute
                $num_children = ($node->childNodes == null) ? 0 : $node->childNodes->length;
+               $children = array();
                for ($i = 0; $i < $num_children; ++$i) {
-                       $child = $node->childNodes->item($i);
+                       $children[] = $node->childNodes->item($i);
+               }
+
+               for ($i = 0; $i < $num_children; ++$i) {
+                       $child = $children[$i];
                        $processed = false;
 
                        if ($child->nodeType == XML_ELEMENT_NODE) {