]> git.sesse.net Git - xml-template/commitdiff
Use getAttributeNodeNS() to kill a tiny bit of PHP5 code.
authorsgunderson@bigfoot.com <>
Sat, 28 Feb 2009 15:51:12 +0000 (16:51 +0100)
committersgunderson@bigfoot.com <>
Sat, 28 Feb 2009 15:51:12 +0000 (16:51 +0100)
php5/xml-template.php

index b28db156ebf2cf6e6ffe1f637a3b579a299e7df8..e6a4e1909d2f0dc4153fbd644ec6797b0040587c 100644 (file)
@@ -49,14 +49,13 @@ function XML_Template_process($node, $obj, $clean = 1)
 
                                if (isset($attrs)) {
                                        $replace_child = 0;
-                                       foreach ($child->attributes as $attr) {
-                                               if ($attr->namespaceURI == 'http://template.sesse.net/' && $attr->name == 'id') {
-                                                       $id = $attr->value;
-                                                       if ($clean) {
-                                                               $child->removeAttributeNode($attr);
-                                                               $replace_child = 1;
-                                                       }
-                                               }
+                                       $id_node = $child->getAttributeNodeNS('http://template.sesse.net/', 'id');
+                                       if (isset($id_node)) {
+                                               $id = $id_node->value;
+                                               if ($clean) {
+                                                       $child->removeAttributeNode($id_node);
+                                                       $replace_child = 1;
+                                               }       
                                        }
 
                                        # This seems to be the only way to reliably get rid of the excess