Class Cdata
Cdata
XML CDATASection
ノードの表現。
// Create and log an XML document that shows how special characters like '<',
// '>', and '&' are stored in a CDATASection node as compared to in a Text node.
const illegalCharacters = '<em>The Amazing Adventures of Kavalier & Clay</em>';
const cdata = XmlService.createCdata(illegalCharacters);
const text = XmlService.createText(illegalCharacters);
const root =
XmlService.createElement('root').addContent(cdata).addContent(text);
const document = XmlService.createDocument(root);
const xml = XmlService.getPrettyFormat().format(document);
Logger.log(xml);
詳細なドキュメント
append(text)
指定されたテキストを、ノード内にすでに存在するコンテンツに追加します。
パラメータ
名前 | 型 | 説明 |
text | String | ノードに追加するテキスト |
戻る
Text
- チェーン用の Text
ノード
detach()
ノードを親の Element
ノードから切断します。ノードに親がない場合、このメソッドは効果がありません。
戻る
Content
- デタッチされたノード
getParentElement()
ノードの親 Element
ノードを取得します。ノードに親がない場合、このメソッドは null
を返します。
戻る
Element
- 親 Element
ノード
getText()
Text
ノードのテキスト値を取得します。
戻る
String
- Text
ノードのテキスト値
getValue()
ノードの直接の子または間接の子であるすべてのノードのテキスト値を、ドキュメントに表示される順序で取得します。
戻る
String
- ノードの直接または間接の子であるすべてのノードのテキスト値
setText(text)
Text
ノードのテキスト値を設定します。
パラメータ
名前 | 型 | 説明 |
text | String | 設定するテキスト値 |
戻る
Text
- チェーン用の Text
ノード
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-12-22 UTC。
[null,null,["最終更新日 2024-12-22 UTC。"],[[["`Cdata` represents an XML `CDATASection` node, allowing you to store special characters like '\u003c', '\u003e', and '&' literally without escaping them."],["It provides methods to manipulate the CDATA content, such as appending text, detaching from the parent element, and retrieving or setting the text value."],["You can create a `Cdata` node using `XmlService.createCdata(text)` and incorporate it into your XML document."],["`Cdata` is particularly useful when dealing with data that contains characters that would otherwise be interpreted as XML markup."],["It offers flexibility in managing the CDATA content within the XML structure through various methods like `append`, `detach`, `getText`, `getValue`, and `setText`."]]],["The document describes an XML `CDATASection` node and its methods. Key actions include creating a `CDATASection` with special characters, contrasting it with a `Text` node, and logging the results. Methods allow appending text, detaching from a parent, getting the parent element, retrieving text value, accessing the value of child nodes, and setting text. These functions enable manipulation and retrieval of the `CDATASection` node's content and structure within an XML document.\n"]]