note 105472 added to class.domdocumentfragment
| From: | outis at osu1 dot php dot net | Date: | Sat, 20 Aug 2011 22:21:03 +0000 |
| Subject: | note 105472 added to class.domdocumentfragment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182614@lists.php.net to get a copy of this message | ||
@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);
----
Server IP: 69.147.83.197
Probable Submitter: 174.30.41.72
----
Manual Page -- http://www.php.net/manual/en/class.domdocumentfragment.php
Edit -- https://master.php.net/note/edit/105472
Del: integrated -- https://master.php.net/note/delete/105472/integrated
Del: useless -- https://master.php.net/note/delete/105472/useless
Del: bad code -- https://master.php.net/note/delete/105472/bad+code
Del: spam -- https://master.php.net/note/delete/105472/spam
Del: non-english -- https://master.php.net/note/delete/105472/non-english
Del: in docs -- https://master.php.net/note/delete/105472/in+docs
Del: other reasons-- https://master.php.net/note/delete/105472
Reject -- https://master.php.net/note/reject/105472
Search -- https://master.php.net/manage/user-notes.php