Loading TOC...

MarkLogic 9 Product Documentation
NodeBuilder.startDocument

NodeBuilder.startDocument(
   [uri as String]
) as This NodeBuilder object

Summary

Start a new document node in the node tree the builder is building.

Parameters
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

const builder = new NodeBuilder();
builder.startDocument('meta.json');
  builder.addNode(
    {author: 'Mary', date: '2014-10-06', keywords: ['example','JSON']} )
builder.endDocument();
builder.toNode();

// Returns a JSON document node equivalent to the following:
//
// {"author":"Mary", "date":"2014-10-06", "keywords":["example", "JSON"]}

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.