#44773 [Opn]: DOMDocumentFragment::appendXML() stumbles over namespaces

From: Date: Fri, 18 Apr 2008 12:06:15 +0000
Subject: #44773 [Opn]: DOMDocumentFragment::appendXML() stumbles over namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124355@lists.php.net to get a copy of this message
ID: 44773 User updated by: daniel dot gorski at develnet dot org Reported By: daniel dot gorski at develnet dot org Status: Open Bug Type: DOM XML related Operating System: Linux PHP Version: 5.3CVS-2008-04-18 (CVS) New Comment: Correction, added missing namespace prefix "name": Expected result: ---------------- <?xml version="1.0"?> <root xmlns:name="..."><name:element>text</name:element></root> Previous Comments: ------------------------------------------------------------------------ [2008-04-18 12:04:38] daniel dot gorski at develnet dot org Description: ------------ The DOMDocumentFragment::appendXML() function spits warnings if it comes to insertion of XML with namespace-prefixed elements. This of course would make sense if the namespaces were not definied, but they are - at least in the parent document. regards dtg Reproduce code: --------------- <?php error_reporting(E_ALL); $doc = new DOMDocument(); $doc->loadXML('<root xmlns:name="..."/>'); $frag = $doc->createDocumentFragment(); $frag->appendXML('<name:element>text</name:element>'); $doc->documentElement->appendChild($frag); echo htmlentities($doc->saveXML()); ?> Expected result: ---------------- <?xml version="1.0"?> <root xmlns:name="..."><element>text</element></root> Actual result: -------------- Warning: DOMDocumentFragment::appendXML() [domdocumentfragment.appendxml]: namespace error : Namespace prefix name on element is not defined in ... on line 9 Warning: DOMDocumentFragment::appendXML() [domdocumentfragment.appendxml]: <name:element>text</name:element> in ... on line 9 Warning: DOMDocumentFragment::appendXML() [domdocumentfragment.appendxml]: ^ in ... on line 9 <?xml version="1.0"?> <root xmlns:name="..."><element>text</element></root> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44773&edit=1

« previous php.bugs (#124355) next »