XML DOM Document Object
- Previous page DOM Comment
- Next Page DOM DocumentType
The Document object represents the entire XML document.
Document object
The Document object is the root of a document tree, which can provide us with the initial (or top-level) access point to the document data.
For element nodes, text nodes, comments, processing instructions, and others that cannot exist outside the document, the document object also provides methods to create these objects. The Node object provides an ownerDocument property, which can associate them with the Document in which they are created.
IE: Internet Explorer: F: Firefox: O: Opera: W3C: World Wide Web Consortium (Internet Standards)
Properties of the Document object
Property | Description | IE | F | O | W3C |
---|---|---|---|---|---|
async | Specify whether the download of the XML file should be processed synchronously. | 5 | 1.5 | 9 | No |
childNodes | Return the node list of the child nodes of the document. | 5 | 1 | 9 | Yes |
doctype | Return the document type declaration (DTD) related to the document. | 6 | 1 | 9 | Yes |
documentElement | Return the root node of the document. | 5 | 1 | 9 | Yes |
documentURI | Set or return the location of the document. | No | 1 | 9 | Yes |
domConfig | Return the configuration used when normalizeDocument() is called. | No | Yes | ||
firstChild | Return the first child node of the document. | 5 | 1 | 9 | Yes |
implementation | Return the DOMImplementation object that handles the document. | No | 1 | 9 | Yes |
inputEncoding | Return the encoding method used for the document (at parsing time). | No | 1 | No | Yes |
lastChild | Return the last child node of the document. | 5 | 1 | 9 | Yes |
nodeName | Return the name of the node based on its type. | 5 | 1 | 9 | Yes |
nodeType | Return the node type of the node. | 5 | 1 | 9 | Yes |
nodeValue | Set or return the value of the node according to its type. | 5 | 1 | 9 | Yes |
strictErrorChecking | Set or return whether to force error checking. | No | 1 | No | Yes |
text | Return the text of the node and its descendants (only for IE). | 5 | No | No | No |
xml | Return the XML of the node and its descendants (only for IE). | 5 | No | No | No |
xmlEncoding | Return the encoding method of the document. | No | 1 | No | Yes |
xmlStandalone | Set or return whether the document is standalone. | No | 1 | No | Yes |
xmlVersion | Set or return the XML version of the document. | No | 1 | No | Yes |
Methods of the Document object
Property | Description | IE | F | O | W3C |
---|---|---|---|---|---|
adoptNode(sourcenode) | Select a node from another document to this document, and then return the selected node. | No | Yes | ||
createAttribute(name) | Create an attribute node with the specified name, and return the new Attr object. | 6 | 1 | 9 | Yes |
createAttributeNS(uri,name) | Create an attribute node with the specified name and namespace, and return the new Attr object. | 9 | Yes | ||
createCDATASection() | Create a CDATA section node. | 5 | 1 | 9 | Yes |
createComment() | Create a comment node. | 6 | 1 | 9 | Yes |
createDocumentFragment() | Create an empty DocumentFragment object, and return this object. | 5 | 1 | 9 | Yes |
createElement() | Create an element node. | 5 | 1 | 9 | Yes |
createElementNS() | Create an element node with the specified namespace. | No | 1 | 9 | Yes |
createEvent() | Create a new Event object. | Yes | |||
createEntityReference(name) | Create an EntityReference object and return this object. | 5 | No | Yes | |
createExpression() | Create an XPath expression for later evaluation. | Yes | |||
createProcessingInstruction() | Create a ProcessingInstruction object and return this object. | 5 | 9 | Yes | |
createRange() | Create a Range object and return this object. | No | Yes | ||
evaluate() | Evaluate an XPath expression. | No | 1 | 9 | Yes |
createTextNode() | Create a text node. | 5 | 1 | 9 | Yes |
getElementById() | Find an element with the specified unique ID. | 5 | 1 | 9 | Yes |
getElementsByTagName() | Return all element nodes with the specified name. | 5 | 1 | 9 | Yes |
getElementsByTagNameNS() | Return all element nodes with the specified name and namespace. | No | 1 | 9 | Yes |
importNode() | Copy a node from another document to this document for application. | 9 | Yes | ||
loadXML() | Compose a document by parsing an XML tag string. | ||||
normalizeDocument() | No | Yes | |||
renameNode() | Rename an element or an attribute node. | No | Yes |
- Previous page DOM Comment
- Next Page DOM DocumentType