Loading TOC...

NodeBuilder.endDocument

NodeBuilder.endDocument() as This NodeBuilder object

Summary

Close out the current document node.

Usage Notes

Document nodes must be completed before calling toNode() on the builder; an error will be raised if they are not. An error will also be raised if endDocument is called when there is an open element node.

Example

const builder = new NodeBuilder();
builder.startDocument();
  builder.addNode( ['array','of','strings'] );
builder.endDocument();
builder.toNode();

// Returns a JSON array node equivalent to the following:
//
// ["array", "of", "strings"]

Example

const builder = new NodeBuilder();
builder.startDocument();
  builder.startElement("dangling")
  builder.addText("Some content");
builder.endDocument();
builder.toNode();

// Throws an exception because the element "dangling" is not terminated.

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