ID:               44773
 Updated by:       [EMAIL PROTECTED]
 Reported By:      daniel dot gorski at develnet dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Linux
 PHP Version:      5.3CVS-2008-04-18 (CVS)
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That's expected behaviour as the namespace is not defined in your 
DocumentFragment (and DocumentFragment doesn't have $doc-
>documentElement as parentNode where the namespace would have been 
defined in your example)

$frag->appendXML('<name:element 
xmlns:name="...">text</name:element>');

solves the problem (but I'm sure, you already knew that :) )


Previous Comments:
------------------------------------------------------------------------

[2008-04-18 12:06:15] daniel dot gorski at develnet dot org

Correction, added missing namespace prefix "name":

Expected result:
----------------
<?xml version="1.0"?> <root
xmlns:name="..."><name:element>text</name:element></root>

------------------------------------------------------------------------

[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

Reply via email to