Zadbaj o dobrą organizację dzięki kolekcji Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Cdata
Węzeł 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.constillegalCharacters='<em>The Amazing Adventures of Kavalier & Clay</em>';constcdata=XmlService.createCdata(illegalCharacters);consttext=XmlService.createText(illegalCharacters);constroot=XmlService.createElement('root').addContent(cdata).addContent(text);constdocument=XmlService.createDocument(root);constxml=XmlService.getPrettyFormat().format(document);Logger.log(xml);
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eCdata\u003c/code\u003e represents an XML \u003ccode\u003eCDATASection\u003c/code\u003e node, allowing you to store special characters like '<', '>', and '&' literally without escaping them.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to manipulate the CDATA content, such as appending text, detaching from the parent element, and retrieving or setting the text value.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a \u003ccode\u003eCdata\u003c/code\u003e node using \u003ccode\u003eXmlService.createCdata(text)\u003c/code\u003e and incorporate it into your XML document.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCdata\u003c/code\u003e is particularly useful when dealing with data that contains characters that would otherwise be interpreted as XML markup.\u003c/p\u003e\n"],["\u003cp\u003eIt offers flexibility in managing the CDATA content within the XML structure through various methods like \u003ccode\u003eappend\u003c/code\u003e, \u003ccode\u003edetach\u003c/code\u003e, \u003ccode\u003egetText\u003c/code\u003e, \u003ccode\u003egetValue\u003c/code\u003e, and \u003ccode\u003esetText\u003c/code\u003e.\u003c/p\u003e\n"]]],["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"],null,["Cdata\n\nA representation of an XML `CDATASection` node.\n\n```javascript\n// Create and log an XML document that shows how special characters like '\u003c',\n// '\u003e', and '&' are stored in a CDATASection node as compared to in a Text node.\nconst illegalCharacters = '\u003cem\u003eThe Amazing Adventures of Kavalier & Clay\u003c/em\u003e';\nconst cdata = XmlService.createCdata(illegalCharacters);\nconst text = XmlService.createText(illegalCharacters);\nconst root =\n XmlService.createElement('root').addContent(cdata).addContent(text);\nconst document = XmlService.createDocument(root);\nconst xml = XmlService.getPrettyFormat().format(document);\nLogger.log(xml);\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [append(text)](#append(String)) | [Text](/apps-script/reference/xml-service/text) | Appends the given text to any content that already exists in the node. |\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 `Text` 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)) | [Text](/apps-script/reference/xml-service/text) | Sets the text value of the `Text` node. |\n\nDetailed documentation \n\n`append(text)` \nAppends the given text to any content that already exists in the node.\n\nParameters\n\n| Name | Type | Description |\n|--------|----------|--------------------------------|\n| `text` | `String` | the text to append to the node |\n\nReturn\n\n\n[Text](/apps-script/reference/xml-service/text) --- the `Text` node, for chaining\n\n*** ** * ** ***\n\n`detach()` \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\nReturn\n\n\n[Content](/apps-script/reference/xml-service/content) --- the detached node\n\n*** ** * ** ***\n\n`get``Parent``Element()` \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\nReturn\n\n\n[Element](/apps-script/reference/xml-service/element) --- the parent `Element` node\n\n*** ** * ** ***\n\n`get``Text()` \nGets the text value of the `Text` node.\n\nReturn\n\n\n`String` --- the text value of the `Text` node\n\n*** ** * ** ***\n\n`get``Value()` \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\nReturn\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)` \nSets the text value of the `Text` node.\n\nParameters\n\n| Name | Type | Description |\n|--------|----------|-----------------------|\n| `text` | `String` | the text value to set |\n\nReturn\n\n\n[Text](/apps-script/reference/xml-service/text) --- the `Text` node, for chaining"]]