Loading TOC...

NodeBuilder.addDocument

NodeBuilder.addDocument(
   $content as String|Function,
   [$uri as String]
) as This NodeBuilder object

Summary

Add a document node to the node tree the builder is building.

Parameters
$content The contents of the document. If the argument is a string, the builder will add a document node containing that string as a text node. If the argument is a function, that function will be executed with the builder as its argument.
$uri The document URI.

Usage Notes

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.

Example

var builder = new NodeBuilder();
builder.addDocument("simple text document", "simple.txt");
builder.toNode();

Example

function makeDocument(b) {
  b.addElement("p","Copyright 2014 Joe's House of Tech. All Rights Reserved.");
};

var builder = new NodeBuilder();
builder.addDocument(makeDocument);
builder.toNode();

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy