note 105472 deleted from class.domdocumentfragment by danbrown
| From: | danbrown@php.net | Date: | Sat, 20 Aug 2011 22:53:01 +0000 |
| Subject: | note 105472 deleted from class.domdocumentfragment by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182615@lists.php.net to get a copy of this message | ||
Note Submitter: outis
----
@Ricky: since a document fragment is a node, the behavior you describe is consistent (nodes without
a document are read-only and cannot be inserted into a document tree before being imported). You can
add a fragment created with
new to a document using
DOMDocument::importNode. However this is of little practical use in part because
importNode creates a new node rather than altering the existing one. The other reason
this helps little is the one you describe: the document fragment will be read-only until imported.
<?php
$fragment = new DOMDocumentFragment();
$fragment = $doc->importNode($fragment);