<h1>xercesc::DOMDocumentFragment Class Reference</h1><!-- doxytag: class="xercesc::DOMDocumentFragment" --><!-- doxytag: inherits="xercesc::DOMNode" -->
<p><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a> is a "lightweight" or "minimal" <aclass="el"href="classxercesc_1_1DOMDocument.html"title="The DOMDocument interface represents the entire XML document.">DOMDocument</a> object.
<areashape="rect"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model..."alt=""coords="47,5,183,35"/></map>
<p><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a> is a "lightweight" or "minimal" <aclass="el"href="classxercesc_1_1DOMDocument.html"title="The DOMDocument interface represents the entire XML document.">DOMDocument</a> object. </p>
<p>It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a <aclass="el"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model...">DOMNode</a> for this purpose. While it is true that a <code><aclass="el"href="classxercesc_1_1DOMDocument.html"title="The DOMDocument interface represents the entire XML document.">DOMDocument</a></code> object could fulfil this role, a <code><aclass="el"href="classxercesc_1_1DOMDocument.html"title="The DOMDocument interface represents the entire XML document.">DOMDocument</a></code> object can potentially be a heavyweight object, depending on the underlying implementation. What is really needed for this is a very lightweight object. <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> is such an object. </p>
<p>Furthermore, various operations -- such as inserting nodes as children of another <code><aclass="el"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model...">DOMNode</a></code> -- may take <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> objects as arguments; this results in all the child nodes of the <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> being moved to the child list of this node. </p>
<p>The children of a <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> node are zero or more nodes representing the tops of any sub-trees defining the structure of the document. <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> nodes do not need to be well-formed XML documents (although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> might have only one child and that child node could be a <code><aclass="el"href="classxercesc_1_1DOMText.html"title="The DOMText interface inherits from DOMCharacterData and represents the textual content...">DOMText</a></code> node. Such a structure model represents neither an HTML document nor a well-formed XML document. </p>
<p>When a <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> is inserted into a <code><aclass="el"href="classxercesc_1_1DOMDocument.html"title="The DOMDocument interface represents the entire XML document.">DOMDocument</a></code> (or indeed any other <code><aclass="el"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model...">DOMNode</a></code> that may take children) the children of the <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> and not the <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> itself are inserted into the <code><aclass="el"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model...">DOMNode</a></code>. This makes the <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> very useful when the user wishes to create nodes that are siblings; the <code><aclass="el"href="classxercesc_1_1DOMDocumentFragment.html"title="DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument...">DOMDocumentFragment</a></code> acts as the parent of these nodes so that the user can use the standard methods from the <code><aclass="el"href="classxercesc_1_1DOMNode.html"title="The DOMNode interface is the primary datatype for the entire Document Object Model...">DOMNode</a></code> interface, such as <code><aclass="el"href="classxercesc_1_1DOMNode.html#ab53ebbb7276d3d20d24cb486f948717c"title="Inserts the node newChild before the existing child node refChild.">insertBefore()</a></code> and <code><aclass="el"href="classxercesc_1_1DOMNode.html#ade4f6d57748def70f0444b004df96a94"title="Adds the node newChild to the end of the list of children of this node.">appendChild()</a></code>.</p>