Interface Content
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เนื้อหา
การนําเสนอโหนด XML ทั่วไป
การใช้คลาส
เอกสารประกอบโดยละเอียด
asCdata()
แคสต์โหนดเป็นโหนด CDATASection
เพื่อวัตถุประสงค์ในการเติมข้อความอัตโนมัติ หาก ContentType
ของโหนดไม่ใช่ CDATA
อยู่แล้ว เมธอดนี้จะแสดงผลเป็น null
รีเทิร์น
Cdata
— โหนด CDATASection
asDocType()
แคสต์โหนดเป็นโหนด DocumentType
เพื่อวัตถุประสงค์ในการเติมข้อความอัตโนมัติ หากContentType
ของโหนดไม่ใช่DOCTYPE
อยู่แล้ว เมธอดนี้จะแสดงผลเป็นnull
รีเทิร์น
DocType
— โหนด DocumentType
asElement()
แคสต์โหนดเป็นโหนด Element
เพื่อวัตถุประสงค์ในการเติมข้อความอัตโนมัติ หากContentType
ของโหนดไม่ใช่ ELEMENT
อยู่แล้ว เมธอดนี้จะแสดงผลเป็น null
รีเทิร์น
Element
— โหนด Element
asEntityRef()
แคสต์โหนดเป็นโหนด EntityReference
เพื่อวัตถุประสงค์ในการเติมข้อความอัตโนมัติ
หาก ContentType
ของโหนดไม่ใช่ ENTITYREF
อยู่แล้ว เมธอดนี้จะแสดงผลเป็น null
รีเทิร์น
EntityRef
— โหนด EntityReference
asProcessingInstruction()
asText()
แคสต์โหนดเป็นโหนด Text
เพื่อวัตถุประสงค์ในการเติมข้อความอัตโนมัติ หาก ContentType
ของโหนดไม่ใช่ TEXT
อยู่แล้ว เมธอดนี้จะแสดงผลเป็น null
รีเทิร์น
Text
— โหนด Text
detach()
แยกโหนดออกจากโหนด Element
หลัก หากโหนดไม่มีโหนดหลัก วิธีนี้จะไม่มีผล
รีเทิร์น
Content
— โหนดที่แยกออก
getParentElement()
รับโหนด Element
หลักของโหนด หากโหนดไม่มีโหนดหลัก วิธีการนี้จะแสดงผลเป็น null
รีเทิร์น
Element
— โหนด Element
หลัก
getType()
รับประเภทเนื้อหาของโหนด
รีเทิร์น
ContentType
— ประเภทเนื้อหาของโหนด
getValue()
รับค่าข้อความของโหนดทั้งหมดที่เป็นโหนดย่อยโดยตรงหรือโดยอ้อมของโหนดนั้นๆ ตามลำดับที่ปรากฏในเอกสาร
รีเทิร์น
String
— ค่าข้อความของโหนดทั้งหมดที่เป็นโหนดย่อยโดยตรงหรือโดยอ้อมของโหนด
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eContent\u003c/code\u003e is a generic representation of an XML node in Google Apps Script and provides methods to interact with it.\u003c/p\u003e\n"],["\u003cp\u003eIt offers various methods to cast the node into specific types like \u003ccode\u003eElement\u003c/code\u003e, \u003ccode\u003eText\u003c/code\u003e, \u003ccode\u003eComment\u003c/code\u003e, etc., for easier manipulation.\u003c/p\u003e\n"],["\u003cp\u003eYou can detach a node from its parent, get its parent element, or retrieve its content type using dedicated methods.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetValue()\u003c/code\u003e helps retrieve the combined text value of all the node's children, providing a way to access its content.\u003c/p\u003e\n"],["\u003cp\u003eImplementing classes include \u003ccode\u003eCdata\u003c/code\u003e, \u003ccode\u003eComment\u003c/code\u003e, \u003ccode\u003eDocType\u003c/code\u003e, \u003ccode\u003eElement\u003c/code\u003e, \u003ccode\u003eEntityRef\u003c/code\u003e, \u003ccode\u003eProcessingInstruction\u003c/code\u003e, and \u003ccode\u003eText\u003c/code\u003e, representing different XML node types.\u003c/p\u003e\n"]]],["This content details a generic XML node and its interactions. It outlines seven specific XML node types: Cdata, Comment, DocType, Element, EntityRef, ProcessingInstruction, and Text. Key actions include casting a node to a specific type using `asType()` methods, which return `null` if the type is incorrect. Other actions involve `detach()` to remove a node from its parent, `getParentElement()` to find the parent, `getType()` to retrieve the content type, and `getValue()` to get the combined text value of child nodes.\n"],null,["# Interface Content\n\nContent\n\nA representation of a generic XML node.\n\n### Implementing classes\n\n| Name | Brief description |\n|------------------------------------------------------------------------------------|------------------------------------------------------------|\n| [Cdata](/apps-script/reference/xml-service/cdata) | A representation of an XML `CDATASection` node. |\n| [Comment](/apps-script/reference/xml-service/comment) | A representation of an XML `Comment` node. |\n| [DocType](/apps-script/reference/xml-service/doc-type) | A representation of an XML `Document``Type` node. |\n| [Element](/apps-script/reference/xml-service/element) | A representation of an XML `Element` node. |\n| [EntityRef](/apps-script/reference/xml-service/entity-ref) | A representation of an XML `Entity``Reference` node. |\n| [ProcessingInstruction](/apps-script/reference/xml-service/processing-instruction) | A representation of an XML `Processing``Instruction` node. |\n| [Text](/apps-script/reference/xml-service/text) | A representation of an XML `Text` node. |\n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| [asCdata()](#asCdata()) | [Cdata](/apps-script/reference/xml-service/cdata) | Casts the node as a [CDATASection](/apps-script/reference/xml-service/cdata) node for the purposes of autocomplete. |\n| [asComment()](#asComment()) | [Comment](/apps-script/reference/xml-service/comment) | Casts the node as a [Comment](/apps-script/reference/xml-service/comment) node for the purposes of autocomplete. |\n| [asDocType()](#asDocType()) | [DocType](/apps-script/reference/xml-service/doc-type) | Casts the node as a [DocumentType](/apps-script/reference/xml-service/doc-type) node for the purposes of autocomplete. |\n| [asElement()](#asElement()) | [Element](/apps-script/reference/xml-service/element) | Casts the node as an [Element](/apps-script/reference/xml-service/element) node for the purposes of autocomplete. |\n| [asEntityRef()](#asEntityRef()) | [EntityRef](/apps-script/reference/xml-service/entity-ref) | Casts the node as a [EntityReference](/apps-script/reference/xml-service/entity-ref) node for the purposes of autocomplete. |\n| [asProcessingInstruction()](#asProcessingInstruction()) | [ProcessingInstruction](/apps-script/reference/xml-service/processing-instruction) | Casts the node as a [ProcessingInstruction](/apps-script/reference/xml-service/processing-instruction) node for the purposes of autocomplete. |\n| [asText()](#asText()) | [Text](/apps-script/reference/xml-service/text) | Casts the node as a [Text](/apps-script/reference/xml-service/text) node for the purposes of autocomplete. |\n| [detach()](#detach()) | [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| [getType()](#getType()) | [ContentType](/apps-script/reference/xml-service/content-type) | Gets the node's content type. |\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\nDetailed documentation\n----------------------\n\n### `as``Cdata()`\n\nCasts the node as a [CDATASection](/apps-script/reference/xml-service/cdata) node for the purposes of autocomplete. If the\nnode's [ContentType](/apps-script/reference/xml-service/content-type) is not already `CDATA`, this method returns `null`.\n\n#### Return\n\n\n[Cdata](/apps-script/reference/xml-service/cdata) --- the `CDATASection` node\n\n*** ** * ** ***\n\n### `as``Comment()`\n\nCasts the node as a [Comment](/apps-script/reference/xml-service/comment) node for the purposes of autocomplete. If the node's\n[ContentType](/apps-script/reference/xml-service/content-type) is not already `COMMENT`, this method returns `null`.\n\n#### Return\n\n\n[Comment](/apps-script/reference/xml-service/comment) --- the `Comment` node, or `null` if the node's content type is not [COMMENT](/apps-script/reference/xml-service/content-type)\n\n*** ** * ** ***\n\n### `as``Doc``Type()`\n\nCasts the node as a [DocumentType](/apps-script/reference/xml-service/doc-type) node for the purposes of autocomplete. If\nthe node's [ContentType](/apps-script/reference/xml-service/content-type) is not already `DOCTYPE`, this method returns `null`.\n\n#### Return\n\n\n[DocType](/apps-script/reference/xml-service/doc-type) --- the `Document``Type` node\n\n*** ** * ** ***\n\n### `as``Element()`\n\nCasts the node as an [Element](/apps-script/reference/xml-service/element) node for the purposes of autocomplete. If the node's\n[ContentType](/apps-script/reference/xml-service/content-type) is not already `ELEMENT`, this method returns `null`.\n\n#### Return\n\n\n[Element](/apps-script/reference/xml-service/element) --- the `Element` node\n\n*** ** * ** ***\n\n### `as``Entity``Ref()`\n\nCasts the node as a [EntityReference](/apps-script/reference/xml-service/entity-ref) node for the purposes of autocomplete.\nIf the node's [ContentType](/apps-script/reference/xml-service/content-type) is not already `ENTITYREF`, this method returns\n`null`.\n\n#### Return\n\n\n[EntityRef](/apps-script/reference/xml-service/entity-ref) --- the `Entity``Reference` node\n\n*** ** * ** ***\n\n### `as``Processing``Instruction()`\n\nCasts the node as a [ProcessingInstruction](/apps-script/reference/xml-service/processing-instruction) node for the purposes of autocomplete. If\nthe node's [ContentType](/apps-script/reference/xml-service/content-type) is not already `PROCESSINGINSTRUCTION`, this method\nreturns `null`.\n\n#### Return\n\n\n[ProcessingInstruction](/apps-script/reference/xml-service/processing-instruction) --- the `Processing``Instruction` node\n\n*** ** * ** ***\n\n### `as``Text()`\n\nCasts the node as a [Text](/apps-script/reference/xml-service/text) node for the purposes of autocomplete. If the node's [ContentType](/apps-script/reference/xml-service/content-type) is not already `TEXT`, this method returns `null`.\n\n#### Return\n\n\n[Text](/apps-script/reference/xml-service/text) --- the `Text` node\n\n*** ** * ** ***\n\n### `detach()`\n\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\n#### Return\n\n\n[Content](#) --- the detached node\n\n*** ** * ** ***\n\n### `get``Parent``Element()`\n\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\n#### Return\n\n\n[Element](/apps-script/reference/xml-service/element) --- the parent `Element` node\n\n*** ** * ** ***\n\n### `get``Type()`\n\nGets the node's content type.\n\n#### Return\n\n\n[ContentType](/apps-script/reference/xml-service/content-type) --- the node's content type\n\n*** ** * ** ***\n\n### `get``Value()`\n\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\n#### Return\n\n\n`String` --- the text value of all nodes that are direct or indirect children of the node"]]