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
节点,用于链式调用
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-22。
[null,null,["最后更新时间 (UTC):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"]]