note 68108 deleted from function.dom-domdocument-createdocumentfragment by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 21:19:43 +0000 |
| Subject: | note 68108 deleted from function.dom-domdocument-createdocumentfragment by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147229@lists.php.net to get a copy of this message | ||
Note Submitter: xavier.pinard at laposte.net
----
The interest of fragment is I think :
- only nodes inside the fragment are inserted,
not the fragment itself when you insert the fragment
- you can append String litteral with the method
DOMDocumentFragment->appendXML()
So, a fragment may look like this :
part of document<li>bla bla </li> ...
This fragment is describe with a fragment description
that may look like this is you use
it as an "XML Fragment Interchange" :
<f:fcs xmlns:f="http://www.w3.org/2001/02/xml-fragment"
[...]
<myOriginalStructure>
[...]
<f:fragbody/>
[...]
</myOriginalStructure>
cf :: http://www.w3.org/TR/xml-fragment
An example could be for "XML Fragment Interchange":
$dom = new DomDocument();
$frag = $dom->createDocumentFragment();
$fragbody = $dom->createElementNS(
'http://www.w3.org/2001/02/xml-package',
'p:body'
);
$frag->appendXML(
'test fragment<ilo>data</ilo> +
an object property +
something else '
);
$fragbody->appendChild($frag);
$dom->appendChild($fragbody);
var_dump($dom->saveXML());