Class Comment
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Kommentar
Eine Darstellung eines XML-Comment
-Knotens.
Methoden
Methode | Rückgabetyp | Kurzbeschreibung |
detach() | Content | Der Knoten wird von seinem übergeordneten Knoten Element getrennt. |
getParentElement() | Element | Ruft den übergeordneten Element -Knoten des Knotens ab. |
getText() | String | Ruft den Textwert des Knotens Comment ab. |
getValue() | String | Ruft den Textwert aller Knoten ab, die direkte oder indirekte untergeordnete Elemente des Knotens sind, in der Reihenfolge, in der sie im Dokument erscheinen. |
setText(text) | Comment | Legt den Textwert des Knotens Comment fest. |
Detaillierte Dokumentation
detach()
Der Knoten wird von seinem übergeordneten Knoten Element
getrennt. Wenn der Knoten kein übergeordnetes Element hat, hat diese Methode keine Auswirkungen.
Rückflug
Content
– der getrennte Knoten
getParentElement()
Ruft den übergeordneten Element
-Knoten des Knotens ab. Wenn der Knoten kein übergeordnetes Element hat, gibt diese Methode null
zurück.
Rückflug
Element
– der übergeordnete Knoten Element
getText()
Ruft den Textwert des Knotens Comment
ab.
Rückflug
String
: Textwert des Knotens Comment
getValue()
Ruft den Textwert aller Knoten ab, die direkte oder indirekte untergeordnete Elemente des Knotens sind, in der Reihenfolge, in der sie im Dokument erscheinen.
Rückflug
String
: Der Textwert aller Knoten, die direkte oder indirekte untergeordnete Knoten des Knotens sind.
setText(text)
Legt den Textwert des Knotens Comment
fest.
Parameter
Name | Typ | Beschreibung |
text | String | Der festzulegende Textwert |
Rückflug
Comment
– der Comment
-Knoten für die Verkettung
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-26 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003eRepresents an XML \u003ccode\u003eComment\u003c/code\u003e node, providing methods for interaction.\u003c/p\u003e\n"],["\u003cp\u003eAllows detachment from parent element, retrieval of parent/text values, and text modification.\u003c/p\u003e\n"],["\u003cp\u003eIncludes \u003ccode\u003egetText()\u003c/code\u003e for the comment's text and \u003ccode\u003egetValue()\u003c/code\u003e for text of all child nodes.\u003c/p\u003e\n"],["\u003cp\u003eOffers \u003ccode\u003esetText()\u003c/code\u003e to modify the comment's text and \u003ccode\u003edetach()\u003c/code\u003e to remove it from its parent.\u003c/p\u003e\n"]]],["An XML `Comment` node can be manipulated using several methods. `detach()` removes the node from its parent element. `getParentElement()` retrieves the parent `Element` node, if any. `getText()` and `getValue()` return the text content of the `Comment` node and its children respectively. The `setText(text)` method updates the text content of the `Comment` node and supports method chaining by returning the updated `Comment` node.\n"],null,["# Class Comment\n\nComment\n\nA representation of an XML `Comment` node. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [detach()](#detach()) | [Content](/apps-script/reference/xml-service/content) | Detaches the node from its parent [Element](/apps-script/reference/xml-service/element) node. |\n| [getParentElement()](#getParentElement()) | [Element](/apps-script/reference/xml-service/element) | Gets the node's parent [Element](/apps-script/reference/xml-service/element) node. |\n| [getText()](#getText()) | `String` | Gets the text value of the `Comment` node. |\n| [getValue()](#getValue()) | `String` | Gets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document. |\n| [setText(text)](#setText(String)) | [Comment](#) | Sets the text value of the `Comment` node. |\n\nDetailed documentation\n----------------------\n\n### `detach()`\n\nDetaches the node from its parent [Element](/apps-script/reference/xml-service/element) node. If the node does not have a parent,\nthis method has no effect.\n\n#### Return\n\n\n[Content](/apps-script/reference/xml-service/content) --- the detached node\n\n*** ** * ** ***\n\n### `get``Parent``Element()`\n\nGets the node's parent [Element](/apps-script/reference/xml-service/element) node. If the node does not have a parent, this method\nreturns `null`.\n\n#### Return\n\n\n[Element](/apps-script/reference/xml-service/element) --- the parent `Element` node\n\n*** ** * ** ***\n\n### `get``Text()`\n\nGets the text value of the `Comment` node.\n\n#### Return\n\n\n`String` --- the text value of the `Comment` node\n\n*** ** * ** ***\n\n### `get``Value()`\n\nGets the text value of all nodes that are direct or indirect children of the node, in the order\nthey appear in the document.\n\n#### Return\n\n\n`String` --- the text value of all nodes that are direct or indirect children of the node\n\n*** ** * ** ***\n\n### `set``Text(text)`\n\nSets the text value of the `Comment` node.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|-----------------------|\n| `text` | `String` | the text value to set |\n\n#### Return\n\n\n[Comment](#) --- the `Comment` node, for chaining"]]