Interface Content

  • A generic XML node is represented by this class.

  • It has implementing classes for various XML node types like Cdata, Comment, DocType, Element, EntityRef, ProcessingInstruction, and Text.

  • Methods allow casting the node to specific types, detaching it from its parent, getting the parent element, determining its type, and retrieving its text value.

Content

A representation of a generic XML node.

Implementing classes

NameBrief description
CdataA representation of an XMLCDATASection node.
CommentA representation of an XMLComment node.
DocTypeA representation of an XMLDocumentType node.
ElementA representation of an XMLElement node.
EntityRefA representation of an XMLEntityReference node.
ProcessingInstructionA representation of an XMLProcessingInstruction node.
TextA representation of an XMLText node.

Methods

MethodReturn typeBrief description
asCdata()CdataCasts the node as aCDATASection node for the purposes of autocomplete.
asComment()CommentCasts the node as aComment node for the purposes of autocomplete.
asDocType()DocTypeCasts the node as aDocumentType node for the purposes of autocomplete.
asElement()ElementCasts the node as anElement node for the purposes of autocomplete.
asEntityRef()EntityRefCasts the node as aEntityReference node for the purposes of autocomplete.
asProcessingInstruction()ProcessingInstructionCasts the node as aProcessingInstruction node for the purposes of autocomplete.
asText()TextCasts the node as aText node for the purposes of autocomplete.
detach()ContentDetaches the node from its parentElement node.
getParentElement()ElementGets the node's parentElement node.
getType()ContentTypeGets the node's content type.
getValue()StringGets the text value of all nodes that are direct or indirect children of the node, in the orderthey appear in the document.

Detailed documentation

asCdata()

Casts the node as aCDATASection node for the purposes of autocomplete. If thenode'sContentType is not alreadyCDATA, this method returnsnull.

Return

Cdata — theCDATASection node


asComment()

Casts the node as aComment node for the purposes of autocomplete. If the node'sContentType is not alreadyCOMMENT, this method returnsnull.

Return

Comment — theComment node, ornull if the node's content type is notCOMMENT


asDocType()

Casts the node as aDocumentType node for the purposes of autocomplete. Ifthe node'sContentType is not alreadyDOCTYPE, this method returnsnull.

Return

DocType — theDocumentType node


asElement()

Casts the node as anElement node for the purposes of autocomplete. If the node'sContentType is not alreadyELEMENT, this method returnsnull.

Return

Element — theElement node


asEntityRef()

Casts the node as aEntityReference node for the purposes of autocomplete.If the node'sContentType is not alreadyENTITYREF, this method returnsnull.

Return

EntityRef — theEntityReference node


asProcessingInstruction()

Casts the node as aProcessingInstruction node for the purposes of autocomplete. Ifthe node'sContentType is not alreadyPROCESSINGINSTRUCTION, this methodreturnsnull.

Return

ProcessingInstruction — theProcessingInstruction node


asText()

Casts the node as aText node for the purposes of autocomplete. If the node'sContentType is not alreadyTEXT, this method returnsnull.

Return

Text — theText node


detach()

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

Return

Content — the detached node


getParentElement()

Gets the node's parentElement node. If the node does not have a parent, this methodreturnsnull.

Return

Element — the parentElement 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 orderthey 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 theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.