Detailed documentation

addContent(content)

Appends the given node to the end of the document. The content argument can be a Content object or any node object that corresponds to a type listed in ContentType. Note, however, that a document can only have one child Element
node, which is implicitly the root Element node.

Parameters

Return

addContent(index, content)

Inserts the given node at the given index among all nodes that are immediate children of the
document. The content argument can be a Content object or any node object
that corresponds to a type listed in ContentType. Note, however, that a document
can only have one child Element node, which is implicitly the root Element
node.

Parameters

Name

Type

Description

index

Integer

the index at which to insert the node among all nodes that are immediate children
of the document

Parameters

Return

Boolean — true if the node was an immediate child and was removed; false if not

removeContent(index)

Removes the node at the given index among all nodes that are immediate children of the
document. If there is no node at the given index, this method returns null.

Parameters

Name

Type

Description

index

Integer

the index for the node among all nodes that are immediate children of the
document

Return

Content — the node that was removed, or null if there is no node at the given index

setDocType(docType)

Sets the document's DocType declaration. If the document already has a different
DocType node, this method overwrites the old node. This method throws an exception if
the document already contains the same DocType node that is being set.