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
節點
getText()
取得 Text
節點的文字值。
回攻員
String
:Text
節點的文字值
getValue()
取得節點的所有直接或間接子項節點的文字值,並依文件中顯示的順序排列。
回攻員
String
:節點的直接或間接子項的所有節點文字值
setText(text)
設定 Text
節點的文字值。
參數
回攻員
Text
:用於鏈結的 Text
節點
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-22 (世界標準時間)。
[null,null,["上次更新時間:2024-12-22 (世界標準時間)。"],[[["`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"]]