NodeBuilder.endDocument() as This NodeBuilder object
Close out the current document node.
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.
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"]
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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.