Interface Content

  • Content is a generic representation of an XML node in Google Apps Script and provides methods to interact with it.

  • It offers various methods to cast the node into specific types like Element, Text, Comment, etc., for easier manipulation.

  • You can detach a node from its parent, get its parent element, or retrieve its content type using dedicated methods.

  • getValue() helps retrieve the combined text value of all the node's children, providing a way to access its content.

  • Implementing classes include Cdata, Comment, DocType, Element, EntityRef, ProcessingInstruction, and Text, representing different XML node types.

Content

A representation of a generic XML node.

Implementing classes

NameBrief description
Cdata A representation of an XML CDATASection node.
Comment A representation of an XML Comment node.
DocType A representation of an XML DocumentType node.
Element A representation of an XML Element node.
EntityRef A representation of an XML EntityReference node.
ProcessingInstruction A representation of an XML ProcessingInstruction node.
Text A representation of an XML Text node.

Methods

MethodReturn typeBrief description
asCdata() Cdata Casts the node as a CDATASection node for the purposes of autocomplete.
asComment() Comment Casts the node as a Comment node for the purposes of autocomplete.
asDocType() DocType Casts the node as a DocumentType node for the purposes of autocomplete.
asElement() Element Casts the node as an Element node for the purposes of autocomplete.
asEntityRef() EntityRef Casts the node as a EntityReference node for the purposes of autocomplete.
asProcessingInstruction() ProcessingInstruction Casts the node as a ProcessingInstruction node for the purposes of autocomplete.
asText() Text Casts the node as a Text node for the purposes of autocomplete.
detach() Content Detaches the node from its parent Element node.
getParentElement() Element Gets the node's parent Element node.
getType() ContentType Gets the node's content type.
getValue() StringGets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document.

Detailed documentation

asCdata()

Casts the node as a CDATASection node for the purposes of autocomplete. If the node's ContentType is not already CDATA, this method returns null.

Return

Cdata — the CDATASection node


asComment()

Casts the node as a Comment node for the purposes of autocomplete. If the node's ContentType is not already COMMENT, this method returns null.

Return

Comment — the Comment node, or null if the node's content type is not COMMENT


asDocType()

Casts the node as a DocumentType node for the purposes of autocomplete. If the node's ContentType is not already DOCTYPE, this method returns null.

Return

DocType — the DocumentType node


asElement()

Casts the node as an Element node for the purposes of autocomplete. If the node's ContentType is not already ELEMENT, this method returns null.

Return

Element — the Element node


asEntityRef()

Casts the node as a EntityReference node for the purposes of autocomplete. If the node's ContentType is not already ENTITYREF, this method returns null.

Return

EntityRef — the EntityReference node


asProcessingInstruction()

Casts the node as a ProcessingInstruction node for the purposes of autocomplete. If the node's ContentType is not already PROCESSINGINSTRUCTION, this method returns null.

Return

ProcessingInstruction — the ProcessingInstruction node


asText()

Casts the node as a Text node for the purposes of autocomplete. If the node's ContentType is not already TEXT, this method returns null.

Return

Text — the Text node


detach()

Detaches the node from its parent Element node. If the node does not have a parent, this method has no effect.

Return

Content — the detached node


getParentElement()

Gets the node's parent Element node. If the node does not have a parent, this method returns null.

Return

Element — the parent Element node


getType()

Gets the node's content type.

Return

ContentType — the node's content type


getValue()

Gets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document.

Return

String — the text value of all nodes that are direct or indirect children of the node

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年12月02日 UTC.