Intro

The Document node contains the entire document, the root node. EG: For XHTML, the root node is <html>.

A Document node has a nodeType=9.

A Document node may have the following kinds of child nodes: Element (maximum of one), ProcessingInstruction, Comment, DocumentType (maximum of one).

Properties

  • doctype. 'The Document Type Declaration (see DocumentType) associated with this document.'.
  • documentElement. 'This is a convenience attribute that allows direct access to the child node that is the document element of the document.'.
  • documentURI. 'The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.'. DOM 3+.
  • domConfig. 'The configuration used when Document.normalizeDocument() is invoked.'. DOM 3+.
  • implementation. 'The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.'. DOM 3+.
  • inputEncoding. 'An attribute specifying the encoding used for this document at the time of the parsing. This is null when it is not known, such as when the Document was created in memory.'. DOM 3+.
  • strictErrorChecking. 'An attribute specifying whether error checking is enforced or not.' true by default. DOM 3+.
  • xmlEncoding. 'An attribute specifying, as part of the XML declaration, the encoding of this document.'. DOM 3+.
  • xmlStandalone. 'An attribute specifying, as part of the XML declaration, whether this document is standalone.'. false by default. DOM 3+.
  • xmlVersion. 'An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is "1.0".'. DOM 3+.

Methods

  • adoptNode(source). 'Attempts to adopt a node from another document to this document.'. Returns the adopted Node. DOM 3+.
  • createAttribute(name). Creates and returns an Attr of the given name.
  • createAttributeNS(namespaceURI,qualifiedName). Creates and returns an Attr of the given qualified name and namespace URI. DOM 2+.
  • createCDATASection(data). Creates and returns a CDATASection node whose value is the specified string.
  • createComment(data). Creates and returns a Comment node given the specified string.
  • createDocumentFragment(). Creates an empty DocumentFragment object.
  • createElement(tagName). Creates and returns an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object. In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
  • createElementNS(namespaceURI,qualifiedName). 'Creates an element of the given qualified name and namespace URI.'. DOM 2+.
  • createEntityReference(i). Creates and returns an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.
  • createProcessingInstruction(target,data). Creates and returns a ProcessingInstruction node given the specified name and data strings.
  • createTextNode(data). Creates and returns a Text node given the specified string.
  • getElementById(elementId). 'Returns the Element that has an ID attribute with the given value. If no such element exists, this returns null. If more than one element has an ID attribute with that value, what is returned is undefined.'. DOM 2+.
  • getElementsByTagName(tagname). 'Returns a NodeList of all the Elements in document order with a given tag name and are contained in the document.'
  • getElementsByTagNameNS(namespaceURI,localName). 'Returns a NodeList of all the Elements with a given local name and namespace URI in document order.'. DOM 2+.
  • importNode(importedNode,deep). 'Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node.' DOM 2+.
  • normalizeDocument(). This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form. As a consequence, this method updates the replacement tree of EntityReference nodes and normalizes Text nodes, as defined in the method Node.normalize().'. DOM 3+.
  • renameNode(n,namespaceURI,qualifiedName). 'Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE. When possible this simply changes the name of the given node, otherwise this creates a new node with the specified name and replaces the existing node with the new node'. DOM 3+


GeorgeHernandez.comSome rights reserved