Class Comment

  • Represents an XML Comment node, providing methods for interaction.

  • Allows detachment from parent element, retrieval of parent/text values, and text modification.

  • Includes getText() for the comment's text and getValue() for text of all child nodes.

  • Offers setText() to modify the comment's text and detach() to remove it from its parent.

Comment

A representation of an XML Comment node.

Methods

MethodReturn typeBrief description
detach()ContentDetaches the node from its parent Element node.
getParentElement()ElementGets the node's parent Element node.
getText()StringGets the text value of the Comment node.
getValue()StringGets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document.
setText(text)CommentSets the text value of the Comment node.

Detailed documentation

detach()

Detaches the node from its parent Element node. If the node does not have a parent, this method has no effect.

Return

Content — the detached node


getParentElement()

Gets the node's parent Element node. If the node does not have a parent, this method returns null.

Return

Element — the parent Element node


getText()

Gets the text value of the Comment node.

Return

String — the text value of the Comment node


getValue()

Gets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document.

Return

String — the text value of all nodes that are direct or indirect children of the node


setText(text)

Sets the text value of the Comment node.

Parameters

NameTypeDescription
textStringthe text value to set

Return

Comment — the Comment node, for chaining