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
노드
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 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"]]