Class Comment

  • Comment is a representation of an XMLComment node.

  • Methods are available to detach the Comment node, get its parent element, and get or set its text value.

  • ThegetValue() method retrieves the text value of all direct or indirect children of the node.

Comment

A representation of an XMLComment node.

Methods

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

Detailed documentation

detach()

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

Return

Content — the detached node


getParentElement()

Gets the node's parentElement node. If the node does not have a parent, this methodreturnsnull.

Return

Element — the parentElement node


getText()

Gets the text value of theComment node.

Return

String — the text value of theComment node


getValue()

Gets the text value of all nodes that are direct or indirect children of the node, in the orderthey 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 theComment node.

Parameters

NameTypeDescription
textStringthe text value to set

Return

Comment — theComment node, for chaining

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-02 UTC.