The W3C DOM represents the document as a hierarchy of Node objects, each of which has more specialized interfaces. Thus each of the other nodes (EG: Element and Attr) will have the properties and methods of Node.

Properties

  • attributes. Returns a NamedNodeMap containing all attributes for this node
  • baseURI. 'The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.'. DOM 3+.
  • childNodes. Returns a NodeList containing all the child nodes for this node
  • firstChild. Returns the first child node for this node
  • lastChild. Returns the last child node for this node
  • localName. 'Returns the local part of the qualified name of this node'. DOM 2+.
  • namespaceURI. 'The namespace URI of this node, or null if it is unspecified'. DOM 2+.
  • nextSibling. Returns the next sibling node. Two nodes are siblings if they have the same parent node
  • nodeName. Returns the nodeName, depending on the type
  • nodeType. Returns the nodeType as a number. 1=Element, 2=Attr, 3=Text, 4=CDATASection, 5=EntityReference, 6=Entity, 7=ProcessingInstruction, 8=Comment, 9=Document, 10=DocumentType, 11=DocumentFragment, 12=Notation. According to the MSDN, MSIE only returns the values of 1 and 3.
  • nodeValue. Returns the value of this node, depending on the type. MSIE and Mozilla also allows this property to set the value of this node. Mozilla will only change the value if one exists while MSIE will create the value from scratch.
  • ownerDocument. Returns the root node of the document
  • parentNode. Returns the parent node for this node
  • prefix. 'The namespace prefix of this node, or null if it is unspecified'. DOM 2+. Not read only.
  • previousSibling. Returns the previous sibling node. Two nodes are siblings if they have the same parent node
  • textContent. 'This attribute returns the text content of this node and its descendants'. DOM 3+. Not read only.

Methods

  • appendChild(newChild). Appends the node newChild at the end of the child nodes for this node
  • cloneNode(boolean). Returns an exact clone of this node. If the boolean value is set to true, the cloned node contains all the child nodes as well
  • compareDocumentPosition(other). 'Compares the reference node, i.e. the node on which this method is being called, with a node, i.e. the one passed as a parameter, with regard to their position in the document and according to the document order.' DOM 3+.
  • getFeature(feature,version). 'This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in DOM Features.'. DOM 3+.
  • getUserData(key). 'Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.' DOM 3+.
  • hasAttributes(). 'Returns whether this node (if it is an element) has any attributes.'. DOM 2+.
  • hasChildNodes(). Returns true if this node has any child nodes
  • insertBefore(newNode,refNode). Inserts a new node, newNode, before the existing node, refNode
  • isDefaultNamespace(namespaceURI). 'This method checks if the specified namespaceURI is the default namespace or not.' DOM 3+.
  • isEqualNode(arg). 'Tests whether two nodes are equal.' DOM 3+.
  • isSameNode(other). 'Returns whether this node is the same node as the given one.'. DOM 3+.
  • isSupported(feature,version). Returns true if 'the DOM implementation implements a specific feature and that feature is supported by this node'. DOM 2+.
  • lookupNamespaceURI(prefix). 'Look up the namespace URI associated to the given prefix, starting from this node.' DOM 3+.
  • lookupPrefix(namespaceURI).
  • normalize(). 'Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups) that depend on a particular document tree structure are to be used. If the parameter "normalize-characters" of the DOMConfiguration object attached to the Node.ownerDocument is true, this method will also fully normalize the characters of the Text nodes.'. DOM 3+.
  • removeChild(nodeName). 'Removes the child node indicated by oldChild from the list of children, and returns it.'
  • replaceChild(newNode,oldNode). 'Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.'
  • setUserData(key,data,handler). 'Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key.'. DOM 3+.


GeorgeHernandez.comSome rights reserved