Loading TOC...

MarkLogic 10 Product Documentation
NodeBuilder.endElement

NodeBuilder.endElement() as This NodeBuilder object

Summary

Close out the current XML element node.

Usage Notes

Element 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 endElement is called when there is no open element node.

Example

const builder = new NodeBuilder();
builder.startElement('p');
  builder.addText('Some content');
builder.endElement();
builder.toNode();

// Returns the following XML element node:
//
// <p>Some content</p>

Example

const builder = new NodeBuilder();
builder.startElement('root')
  builder.addText('Some content');
builder.endElement();
builder.endElement();
builder.toNode();

// throws an XDMP-ENDELEMENT exception

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