Next / Previous / Contents / TCC Help System / NM Tech homepage

12.5. Document.createDocumentFragment()

Sometimes you want to generate only part of a document. For example, you may want to generate only the body element of an XHTML page. If you used a Document object, when you printed it you would get an unnecessary <?xml ... ?> declaration at the beginning of the output.

So in this case you should use the DocumentFragment constructor on a Document object D:

D.createDocumentFragment()

The method returns a DocumentFragment object; use this object as you would a Document node, as a parent for Element nodes. When printed, it will not start with an XML declaration.