From: sgunderson@bigfoot.com <> Date: Sat, 26 Apr 2008 16:07:54 +0000 (+0200) Subject: Fix a problem with older (?) PHP5 not having a childNodes entry on X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=86bc564142b279461bd97cc752b7138fa03c6417 Fix a problem with older (?) PHP5 not having a childNodes entry on DOMTextNodes. --- diff --git a/php5/xml-template.php b/php5/xml-template.php index 54d1452..f4581ff 100644 --- a/php5/xml-template.php +++ b/php5/xml-template.php @@ -32,7 +32,8 @@ function XML_Template_process($node, $obj, $clean = 1) $doc = $node->ownerDocument; $node->appendChild($doc->createTextNode($obj)); } else if (is_associative_array($obj)) { # substitute - for ($i = 0; $i < $node->childNodes->length; ++$i) { + $num_children = ($node->childNodes == null) ? 0 : $node->childNodes->length; + for ($i = 0; $i < $num_children; ++$i) { $child = $node->childNodes->item($i); $processed = false;