]> git.sesse.net Git - xml-template/blobdiff - php5/xml-template.php
Implement prettyprinting in the PHP5 SWIG version.
[xml-template] / php5 / xml-template.php
index 46047ff8ff27730c09bdc5c91a4d91a6695b93e2..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
@@ -209,7 +208,7 @@ function own_clone_element($node, $doc)
                        }
 
                        # You've got to be kidding me...
-                       $attr2->value = htmlentities($attr->value);
+                       $attr2->value = preg_replace("/&/", "&", $attr->value);
                        $newnode->appendChild($attr2);
                }
        }