Stay organized with collections Save and categorize content based on your preferences.
DocumentA representation of an XML document.
Detailed documentationaddContent(content)
Appends the given node to the end of the document. The content
argument can be a Content
object or any node object that corresponds to a type listed in ContentType
. Note, however, that a document can only have one child Element
node, which is implicitly the root Element
node.
content
Content
the node to append Return
Document
— the document, for chaining
addContent(index, content)
Inserts the given node at the given index among all nodes that are immediate children of the document. The content
argument can be a Content
object or any node object that corresponds to a type listed in ContentType
. Note, however, that a document can only have one child Element
node, which is implicitly the root Element
node.
index
Integer
the index at which to insert the node among all nodes that are immediate children of the document content
Content
the node to insert Return
Document
— the document, for chaining
cloneContent()
Creates unattached copies of all nodes that are immediate children of the document.
ReturnContent[]
— an array of unattached copies of all nodes that are immediate children of the document
detachRootElement()
Detaches and returns the document's root Element
node. If the document does not have a root Element
node, this method returns null
.
Element
— the detached Element
node, or null
if the document does not have a root Element
node
getAllContent()
Gets all nodes that are immediate children of the document.
ReturnContent[]
— an array of all nodes that are immediate children of the document
getContent(index)
Gets the node at the given index among all nodes that are immediate children of the document. If there is no node at the given index, this method returns null
.
index
Integer
the index for the node among all nodes that are immediate children of the document Return
Content
— the node, or null
if there is no node at the given index
getContentSize()
Gets the number of nodes that are immediate children of the document.
ReturnInteger
— the number of nodes that are immediate children of the document
getDescendants()
Gets all nodes that are direct or indirect children of the document, in the order they appear in the document.
ReturnContent[]
— an array of all nodes that are direct or indirect children of the document
getDocType()
Gets the document's DocType
declaration. If the document does not have a DocumentType
node, this method returns null
.
DocType
— the DocumentType
node, or null
if the document does not have a DocumentType
node
getRootElement()
Gets the document's root Element
node. If the document does not have a root Element
node, this method returns null
.
Element
— the root Element
node, or null
if the document does not have a root Element
node
hasRootElement()
Determines whether the document has a root Element
node.
Boolean
— true
if the document has a root Element
node; false
if not
removeContent()
Removes all nodes that are immediate children of the document.
ReturnContent[]
— an array of all nodes that were immediate children of the document before they were removed
removeContent(content)
Removes the given node, if the node is an immediate child of the document. The content
argument can be a Content
object or any node object that corresponds to a type listed in ContentType
.
content
Content
the node to remove Return
Boolean
— true
if the node was an immediate child and was removed; false
if not
removeContent(index)
Removes the node at the given index among all nodes that are immediate children of the document. If there is no node at the given index, this method returns null
.
index
Integer
the index for the node among all nodes that are immediate children of the document Return
Content
— the node that was removed, or null
if there is no node at the given index
setDocType(docType)
Sets the document's DocType
declaration. If the document already has a different DocType
node, this method overwrites the old node. This method throws an exception if the document already contains the same DocType
node that is being set.
docType
DocType
the DocumentType
to set Return
Document
— the document, for chaining
setRootElement(element)
Sets the document's root Element
node. If the document already has a root Element
node, this method overwrites the old node.
element
Element
the root Element
node to set Return
Document
— the document, for chaining
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-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["A Document object represents an XML document and provides methods to manage its content and structure."],["You can manipulate a Document by adding, removing, or accessing its child nodes, including the root Element."],["Several methods are available to retrieve specific nodes or collections of nodes within the document."],["Document methods allow for setting and modifying the DocType and root Element of the XML document."],["Each method is detailed with its parameters, return type, and a brief description of its function."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4