MarkLogic 9 Product Documentation
NodeBuilder.startElement

NodeBuilder.startElement(
   name as String,
   [namespace as String?]
) as This NodeBuilder object

Summary

Start a new XML element node in the node tree the builder is building.

Parameters
name The name of the element. This can be either a simple name, if the element has no namespace, or a QName.
namespace The namespace URI associated with the prefix in the name.

Usage Notes

Element nodes may only be added to element nodes or document nodes.

To add a namespaced element, give a prefixed name as the first argument and a namespace URI as the final argument.

Example

const builder = new NodeBuilder();
builder.startElement('ex:example','http://example.com/ns1');
  builder.addText('Some element content here');
builder.endElement();
builder.toNode();

// Returns the following XML element node:
//
//  <ex:example xmlns:ex="http://example.com/ns1">
//    Some element content here
//  </ex:example>
Powered by MarkLogic Server | Terms of Use | Privacy Policy