#44814 [Bgs]: cannot properly return DOMDocumentFragment
| From: | anthony at createvibe dot com | Date: | Thu, 24 Apr 2008 17:05:51 +0000 |
| Subject: | #44814 [Bgs]: cannot properly return DOMDocumentFragment | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124485@lists.php.net to get a copy of this message | ||
ID: 44814
User updated by: anthony at createvibe dot com
Reported By: anthony at createvibe dot com
Status: Bogus
Bug Type: DOM XML related
Operating System: linux
PHP Version: 5.2.5
New Comment:
Thank you! I tried to importNode in my application, but not in my
example. The importNode didn't work for some reason, but seeing that it
does work in my small example, I'll figure it out from there.
Previous Comments:
------------------------------------------------------------------------
[2008-04-24 12:32:33] chregu@php.net
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
You need to import every node, if you want to use it in another
document.
$dom->appendChild( $dom->importNode(get_frag(),true) );
works in your example
------------------------------------------------------------------------
[2008-04-24 11:09:34] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
------------------------------------------------------------------------
[2008-04-24 04:11:58] anthony at createvibe dot com
Description:
------------
When I create a document fragment via,
DOMDocument::createDocumentFragment() and append child nodes to this
fragment (not sure if the 2nd step is crucial to reproducing this bug),
then try to return the document fragment and then try to append that
fragment to another DOMDocument, I receive a DOMException / Wrong
Document error.
Reproduce code:
---------------
function get_frag()
{
$dom = new DOMDocument;
$frag = $dom->createDocumentFragment();
$frag->appendChild( $dom->createElement('br') );
return( $frag );
}
$dom = new DOMDocument;
$dom->appendChild( get_frag() );
echo $dom->saveXML();
Expected result:
----------------
<?xml version="1.0"?>
<br/>
Actual result:
--------------
( ! ) DOMException: Wrong Document Error in ... test_bug.php on line
10
Call Stack
# Time Memory Function Location
1 0.0004 62056 {main}( ) ../test_bug.php:0
2 0.0006 63780 DOMNode->appendChild( class DOMDocumentFragment { }
) ../test_bug.php:10
Dump $_SERVER
$_SERVER['REQUEST_URI'] =
string '/test_bug.php' (length=13)
Variables in local scope (#1)
$dom =
object(DOMDocument)[1]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44814&edit=1