การแสดงโหนด CDATASection ของ XML
// 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 | ผนวกข้อความที่ระบุกับเนื้อหาที่มีอยู่ในโหนด |
detach() | Content|null | แยกโหนดออกจากโหนด Element หลัก |
get | Element|null | รับโหนด Element หลักของโหนด |
get | String | รับค่าข้อความของโหนด Text |
get | String | รับค่าข้อความของโหนดทั้งหมดที่เป็นโหนดย่อยโดยตรงหรือโดยอ้อมของโหนดตามลำดับที่ปรากฏในเอกสาร |
set | Text | กำหนดค่าข้อความของโหนด Text |
เอกสารโดยละเอียด
append(text)
ผนวกข้อความที่ระบุกับเนื้อหาที่มีอยู่ในโหนด
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
text | String | ข้อความที่จะผนวกกับโหนด |
รีเทิร์น
Text \- โหนด Text สำหรับการเชื่อมโยง
detach()
getParentElement()
getText()
รับค่าข้อความของโหนด Text
รีเทิร์น
String \- ค่าข้อความของโหนด Text
getValue()
รับค่าข้อความของโหนดทั้งหมดที่เป็นโหนดย่อยโดยตรงหรือโดยอ้อมของโหนดตามลำดับที่ปรากฏในเอกสาร
รีเทิร์น
String \- ค่าข้อความของโหนดทั้งหมดที่เป็นโหนดย่อยโดยตรงหรือโดยอ้อมของโหนด
setText(text)
กำหนดค่าข้อความของโหนด Text
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
text | String | ค่าข้อความที่จะกำหนด |
รีเทิร์น
Text \- โหนด Text สำหรับการเชื่อมโยง