--TEST-- Node renaming --EXTENSIONS-- dom --FILE-- XML); function test($target, $namespaceURI, $qualifiedName) { $namespaceURIPretty = json_encode($namespaceURI); $qualifiedNamePretty = json_encode($qualifiedName); echo "--- rename to $namespaceURIPretty $qualifiedNamePretty ---\n"; $target->rename($namespaceURI, $qualifiedName); echo $target->ownerDocument->saveXML(), "\n"; var_dump($target->namespaceURI, $target->prefix); } echo "=== Element test ===\n"; test($dom->documentElement, "urn:x", "x:foo"); test($dom->documentElement, "urn:x", "a:foo"); test($dom->documentElement, "", "foo"); test($dom->documentElement, null, "bar"); echo "=== Attribute test ===\n"; $attribute = $dom->documentElement->firstElementChild->attributes[0]; test($attribute, "urn:x", "x:foo"); test($attribute, "urn:x", "a:foo"); test($attribute, "", "foo"); test($attribute, null, "bar"); ?> --EXPECT-- === Element test === --- rename to "urn:x" "x:foo" --- string(5) "urn:x" string(1) "x" --- rename to "urn:x" "a:foo" --- string(5) "urn:x" string(1) "a" --- rename to "" "foo" --- NULL NULL --- rename to null "bar" --- NULL NULL === Attribute test === --- rename to "urn:x" "x:foo" --- string(5) "urn:x" string(1) "x" --- rename to "urn:x" "a:foo" --- string(5) "urn:x" string(1) "a" --- rename to "" "foo" --- NULL NULL --- rename to null "bar" --- NULL NULL