NodeBuilder.addDocument( content as String|Function, [uri as String] ) as This NodeBuilder object
Add a document node to the node tree the builder is building.
Document nodes may only be added to an empty node tree.
There is no relationship between the URI of the document and the nodes that may be added to that document. In particular, "example.xml" could contain JSON nodes, and "example.json" could contain XML nodes.
const builder = new NodeBuilder(); builder.addDocument('simple text document', 'simple.txt'); builder.toNode(); // Returns a text document node containing "simple text document".
function makeDocument(b) { b.addElement('p','Copyright 2014 Joe\'s House of Tech. All Rights Reserved.'); }; const builder = new NodeBuilder(); builder.addDocument(makeDocument); builder.toNode(); // Returns a document node with the following contents: // <?xml version="1.0" encoding="UTF-8"?> // <p>Copyright 2014 Joe's House of Tech. All Rights Reserved.</p>