Packagedom.core
Classpublic class Node
InheritanceNode Inheritance Object
Implements EventTarget
Subclasses Attr, CharacterData, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction, XPathNamespace

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

A Node is an interface from which a number of DOM types inherit, and allows these various types to be treated (or tested) similarly. The following all inherit this interface and its methods and properties (though they may return null in particular cases where not relevant (or throw an exception when adding children to a node type for which no children can exist)): Document, Element, Attr, CharacterData (which Text, Comment, and CDATASection inherit), ProcessingInstruction, DocumentFragment, DocumentType, Notation, Entity, EntityReference

See also

MDC - Node
W3C - Node


Public Properties
 PropertyDefined By
  DOM 1 Core attributes : NamedNodeMap
[read-only] Returns an unordered collection of Attr nodes.
Node
  Non-Standard baseName : DOMString
[read-only] Returns the base name for the name qualified with the namespace.
Node
  DOM 3 Core baseURI : DOMString
[read-only] The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.
Node
  DOM 1 Core childNodes : NodeList
[read-only] Returns an ordered collection of node objects that are children of the current element.
Node
  Non-Standard dataType : *
Specifies the data type for this node.
Node
  Non-Standard definition : Node
[read-only] Returns the definition of the node in the document type definition (DTD) or schema.
Node
  DOM 1 Core firstChild : Node
[read-only] Returns the node's first child in the tree, or null if the node is childless.
Node
  DOM 1 Core lastChild : Node
[read-only] Returns the last child of a node.
Node
  DOM 2 Core localName : DOMString
[read-only] Returns the local part of the qualified name of this node.
Node
  DOM 2 Core namespaceURI : DOMString
[read-only] The namespace URI of the node, or null if it is unspecified (read-only).
Node
  DOM 1 Core nextSibling : Node
[read-only] Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list.
Node
  DOM 1 Core nodeName : DOMString
[read-only] Returns the name of the current node as a string.
Node
  Non-Standard nodePrincipal : nsIPrincipal
[read-only] Returns the nsIPrincipal object representing current security context of the node.
Node
  DOM 1 Core nodeType : Number
[read-only] Returns an integer code representing the type of the node.
Node
  Non-Standard nodeTypedValue : *
Contains the node value expressed in its defined data type.
Node
  Non-Standard nodeTypeString : DOMString
[read-only] Returns the node type in string form.
Node
  DOM 1 Core nodeValue : DOMString
Returns or sets the value of the current node.
Node
  DOM 1 Core ownerDocument : Document
[read-only] The Document object associated with this node.
Node
  DOM 1 Core parentNode : Node
[read-only] Returns the parent of the specified node in the DOM tree.
Node
  Non-Standard parsed : Boolean
[read-only] Indicates the parsed status of the node and child nodes.
Node
  DOM 2 Core prefix : DOMString
Returns the namespace prefix of the specified node, or null if no prefix is specified.
Node
  DOM 1 Core previousSibling : Node
[read-only] Returns the node immediately preceding the specified one in its parent's childNodes list, null if the specified node is the first in that list.
Node
  Non-Standard specified : Boolean
[read-only] Indicates whether the node (usually an attribute) is explicitly specified or derived from a default value in the document type definition (DTD) or schema.
Node
  Non-Standard text : DOMString
Represents the text content of the node or the concatenated text representing the node and its descendants.
Node
  DOM 3 Core textContent : DOMString
Gets or sets the text content of a node and its descendants.
Node
  Non-Standard xml : DOMString
[read-only] Contains the XML representation of the node and all its descendants.
Node
Public Methods
 MethodDefined By
  
DOM 2 Events addEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Associates a function with a particular event and binds the event to the current node.
Node
  
DOM 3 Events addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Registers an event listener, depending on the useCapture parameter, on the capture phase of the DOM event flow or its target and bubbling phases.
Node
  
DOM 1 Core appendChild(element:Node):Node
Adds a node to the end of the list of children of a specified parent node.
Node
  
DOM 1 Core cloneNode(cloneChildren:Boolean):Node
Returns a duplicate of the current node.
Node
  
DOM 3 Core compareDocumentPosition(other:Node):Number
Compares the position of the current node against another node in any other document.
Node
  
DOM 2 Events dispatchEvent(evt:Event):Boolean
Dispatches an event to fire on a node artificially.
Node
  
DOM 3 Core getFeature(feature:DOMString, version:DOMString):DOMObject
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in DOM Features.
Node
  
Retrieves the object associated to a key on a this node.
Node
  
DOM 2 Core hasAttributes():Boolean
Returns a boolean value of true or false, indicating if the current element has any attributes or not.
Node
  
DOM 1 Core hasChildNodes():Boolean
Returns a value that indicates whether the object has children.
Node
  
DOM 1 Core insertBefore(newNode:Node, childNode:Node):Node
Inserts the specified node before a reference element as a child of the current node.
Node
  
DOM 3 Core isDefaultNamespace(namespaceURI:DOMString):Boolean
Returns true if the namespace is the default namespace on the given node or false if not.
Node
  
DOM 3 Core isEqualNode(arg:Node):Boolean
Tests whether two nodes are equal.
Node
  
DOM 3 Core isSameNode(other:Node):Boolean
Returns whether this node is the same node as the given one.
Node
  
DOM 2 Core isSupported(feature:DOMString, version:DOMString):Boolean
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
Node
  
Takes a prefix and returns the namespaceURI associated with it on the given node if found (and null if not).
Node
  
DOM 3 Core lookupPrefix(namespaceURI:DOMString):DOMString
Returns the prefix for a given namespaceURI if present, and null if not.
Node
  
DOM 1 Core normalize():void
Puts the specified node and all of its subtree into a "normalized" form.
Node
  
DOM 1 Core removeChild(node:Node):Node
Removes a child node from the object.
Node
  
DOM 2 Events removeEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener.
Node
  
DOM 3 Events removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener.
Node
  
DOM 1 Core replaceChild(newNode:Node, childNode:Node):Node
Replaces an existing child element with a new child element.
Node
  
Non-Standard selectNodes(queryString:DOMString):NodeList
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as IXMLDOMNodeList.
Node
  
Non-Standard selectSingleNode(queryString:DOMString):Node
Applies the specified pattern-matching operation to this node's context and returns the first matching node.
Node
  
Associate an object to a key on this node.
Node
  
Non-Standard transformNode(styleSheet:Node):DOMString
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.
Node
  
Non-Standard transformNodeToObject(styleSheet:Node, outputObject:*):void
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.
Node
Public Constants
 ConstantDefined By
  DOM 1 Core ATTRIBUTE_NODE : Number = 2
[static] The node is an Attr.
Node
  DOM 1 Core CDATA_SECTION_NODE : Number = 4
[static] The node is a CDATASection.
Node
  DOM 1 Core COMMENT_NODE : Number = 8
[static] The node is a Comment.
Node
  DOM 1 Core DOCUMENT_FRAGMENT_NODE : Number = 11
[static] The node is a DocumentFragment.
Node
  DOM 1 Core DOCUMENT_NODE : Number = 9
[static] The node is a Document.
Node
  DOM 3 Core DOCUMENT_POSITION_CONTAINED_BY : Number = 16
[static] The node is contained by the reference node.
Node
  DOM 3 Core DOCUMENT_POSITION_CONTAINS : Number = 8
[static] The node contains the reference node.
Node
  DOM 3 Core DOCUMENT_POSITION_DISCONNECTED : Number = 1
[static] The two nodes are disconnected.
Node
  DOM 3 Core DOCUMENT_POSITION_FOLLOWING : Number = 4
[static] The node follows the reference node.
Node
  DOM 3 Core DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : Number = 32
[static] The determination of preceding versus following is implementation-specific.
Node
  DOM 3 Core DOCUMENT_POSITION_PRECEDING : Number = 2
[static] The second node precedes the reference node.
Node
  DOM 1 Core DOCUMENT_TYPE_NODE : Number = 10
[static] The node is a DocumentType.
Node
  DOM 1 Core ELEMENT_NODE : Number = 1
[static] The node is an Element.
Node
  DOM 1 Core ENTITY_NODE : Number = 6
[static] The node is an Entity.
Node
  DOM 1 Core ENTITY_REFERENCE_NODE : Number = 5
[static] The node is an EntityReference.
Node
  DOM 1 Core NOTATION_NODE : Number = 12
[static] The node is a Notation.
Node
  DOM 1 Core PROCESSING_INSTRUCTION_NODE : Number = 7
[static] The node is a ProcessingInstruction.
Node
  DOM 1 Core TEXT_NODE : Number = 3
[static] The node is a Text node.
Node
Property Detail
DOM 1 Core attributesproperty
attributes:NamedNodeMap  [read-only]

Introduced in: DOM 1 Core 

Returns an unordered collection of Attr nodes. If the element has no specified attributes, then the returned object has a length of 0 (zero).

Note: Trying to modify an Attribute Node that originated from an inline event assignment (e.g. onclick=) is something developers should avoid. If you want to use it, be aware that assigning values through the element.attributeName syntax will assign the JavaScript value for the element. When read through the same syntax, it will return the latest JavaScript value for the element attribute, or if it hasn't been assigned yet, the function generated by parsing the element's inline event assignment.

Note: Style isn't a "true" HTML attribute node, but a CCSStyleDeclaration. You can however use the above .attributes syntaxes and DOM functions to control its value, as well as the element.style.cssText syntax that returns all CSS attributes, or element.style.CSSattributeName (eg element.style.position) to control a single CSS attribute. In FireFox, all the above correctly update the CCSStyleDeclaration object, the element's attribute nodes and the .attributes collection. Consider quirksmode for compatibility issues in other browsers (see link below)


Implementation
    public function get attributes():NamedNodeMap

See also


Example
Numerical indexing is useful for going through all of an element's attributes. The following example runs through the attribute nodes for the element in the document with id "p1", and prints each attribute's value.
         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
         "http://www.w3.org/TR/html4/strict.dtd">
         
         <html>
         
             <head>
                 <title>Attributes example</title>
                 <script type="text/javascript">
         
                     function showFirstAttr() {
                         var firstPara = document.getElementById("p1");
                         var outputText = document.getElementById("result");
         
                         // First, let's verify that the paragraph has some attributes    
                         if (firstPara.hasAttributes()) {
                             var attrs = firstPara.attributes;
                             var text = ""; 
                             for(var i=attrs.length-1; i>=0; i--) {
                                 text += attrs[i].name + "->" + attrs[i].value;
                             }
                             outputText.value = text;
                         } else {
                             outputText.value = "No attributes to show"
                         };
                     }
                 </script>
             </head>
         
             <body>
                 <p id="p1" style="color: green;">Sample Paragraph</p>
         
                 <form action="">
                     <p><input type="button" value="Show first attribute name and value"
                         onclick="showFirstAttr();">
                     <input id="result" type="text" value=""></p>
                 </form>
             </body>
         </html>
baseNameproperty 
baseName:DOMString  [read-only]

Non-standard (Microsoft)

Returns the base name for the name qualified with the namespace.

It returns the right-hand side of a namespace qualified name. For example, it returns yyy for the element <xxx:yyy>. It always returns a non-empty string.


Implementation
    public function get baseName():DOMString

See also

DOM 3 Core baseURIproperty 
baseURI:DOMString  [read-only]

Introduced in: DOM 3 Core 

The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI. This value is computed as described in Base URIs. However, when the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed using first the value of the href attribute of the HTML BASE element if any, and the value of the documentURI attribute from the Document interface otherwise.


Implementation
    public function get baseURI():DOMString

See also

DOM 1 Core childNodesproperty 
childNodes:NodeList  [read-only]

Introduced in: DOM 1 Core 

Returns an ordered collection of node objects that are children of the current element. If the element has no children, then the returned NodeList contains no node.

Note: The items in the collection of nodes are objects and not strings. To get data from those node objects, you must use their properties (e.g. elementNodeReference.childNodes[1].nodeName to get the name, etc.).

Note: The document object itself has 2 children: the Doctype declaration and the root element, typically referred to as documentElement. (In (X)HTML documents this is the HTML element.)


Implementation
    public function get childNodes():NodeList

See also


Example
         // parg is an object reference to a <p> element
         if (parg.hasChildNodes()) {
             // So, first we check if the object is not empty, if the object has child nodes
             var children = parg.childNodes;
             for (var i = 0; i < children.length; i++) {
                 // do something with each child as children[i]
                 // NOTE: List is live, Adding or removing children will change the list
             };
         };
         // This is one way to remove all children from a node
         // box is an object refrence to an element with children
         while (box.firstChild) {
             //The list is LIVE so it will re-index each call
             box.removeChild(box.firstChild);
         };
dataTypeproperty 
dataType:*

Non-standard (Microsoft)

Specifies the data type for this node.

ValueDescription
NODE_ATTRIBUTEContains the string representation of the data type specifier included in the schema, or Null if no data type is specified.
NODE_CDATA_SECTION, NODE_COMMENT, NODE_DOCUMENT, NODE_DOCUMENT_FRAGMENT, NODE_DOCUMENT_TYPE, NODE_ENTITY, NODE_NOTATION, NODE_PROCESSING_INSTRUCTION, NODE_TEXTContains the constant string value "string." These node types do not have data types, so the dataType property cannot be set for these node types. Attempts to set this property are ignored.
NODE_ELEMENTContains the string representation of the data type specifier included on the instance of the element or in the schema, or Null if no data type is specified.
NODE_ENTITY_REFERENCEContains the string representation of the data type specifier for the referenced entity. This is limited to entities with a single data type on the root level element of the subtree corresponding to the entity. Contains Null if no data type is specified. It is not possible to set the data type of an entity reference. The data type must be set directly on the referenced element. Attempts to set the value of the dataType property are ignored.


Implementation
    public function get dataType():*
    public function set dataType(value:any):void

See also

definitionproperty 
definition:Node  [read-only]

Non-standard (Microsoft)

Returns the definition of the node in the document type definition (DTD) or schema.

ValueDescription
NODE_ENTITY_REFERENCEReturns the node for the entity referenced; that is, the ENTITY element that was defined for a given ENTITYREF. Given the ENTITYREF &x;, for example, the definition property returns the node in the DOCTYPE node's entity collection that defines the corresponding ENTITY: <!ENTITY x "y">.
NODE_ENTITYFor unparsed entities, returns the NOTATION definition from the DOCTYPE node's notation collection. For example, given the ENTITY <!ENTITY networth SYSTEM "networth.xls" NDATA XLS>, the definition property returns the node corresponding to the notation <!NOTATION XLS PUBLIC "http://example.microsoft.com/office/excel">. For parsed entities, returns Null.
NODE_ATTRIBUTEReturns the XML-Data Schema AttributeType for a given ATTRIBUTE node. For example, the definition property for the attribute myAttribute="123" returns the node corresponding to the element <AttributeType name= "myAttribute"> in the schema. Returns Null when a DTD is used or when no schema is present.
NODE_ELEMENTReturns the XML-Data Schema ElementType for a given ELEMENT node. For example, given the element <myelement>, the definition property returns the node <ElementType name="myelement"> in the specified external schema. Returns Null when a DTD is used or when no schema is present.
NODE_CDATA_SECTION, NODE_COMMENT, NODE_DOCUMENT, NODE_DOCUMENT_FRAGMENT, NODE_DOCUMENT_TYPE, NODE_NOTATION, NODE_PROCESSING_INSTRUCTION, NODE_TEXTReturns Null.


Implementation
    public function get definition():Node

See also

DOM 1 Core firstChildproperty 
firstChild:Node  [read-only]

Introduced in: DOM 1 Core 

Returns the node's first child in the tree, or null if the node is childless. If the node is a Document, it returns the first node in the list of its direct children.

Note: When applied to a document node, the returned node is not necessarily the root element of the document; it can also be a processing instruction, for example. If you need the root element, use document.documentElement.


Implementation
    public function get firstChild():Node

See also


Example
This example demonstrates the use of firstChild and how whitespace nodes might interfere with using this property.
         <p id="para-01">
             <span>First span</span>
         </p>
         
         <script type="text/javascript">
             var p01 = document.getElementById('para-01');
             alert(p01.firstChild.nodeName);
         </script>

In the above, the alert will show '#text' because a text node is inserted to maintain the whitespace between the end of the opening <p> and <span> tags. Any whitespace will cause the #text node to be inserted, from a single space to any number of spaces, returns, tabs, and so on.

Another #text node is inserted between the closing </span> and </p> tags.

If this whitespace is removed from the source, the #text nodes are not inserted and the span element becomes the paragraph's first child.

         <p id="para-01"><span>First span</span></p>
         
         <script type="text/javascript">
             var p01 = document.getElementById('para-01');
             alert(p01.firstChild.nodeName)
         </script>

Now the alert will show 'SPAN'.

DOM 1 Core lastChildproperty 
lastChild:Node  [read-only]

Introduced in: DOM 1 Core 

Returns the last child of a node. Returns null if there are no child elements.


Implementation
    public function get lastChild():Node

See also


Example
         var tr = document.getElementById("row1");
         corner_td = tr.lastChild;
DOM 2 Core localNameproperty 
localName:DOMString  [read-only]

Introduced in: DOM 2 Core 

Returns the local part of the qualified name of this node.

Note: The local name of a node is that part of the node's qualified name that comes after the colon. Qualified names are typically used in XML as part of the namespace(s) of the particular XML documents. For example, in the qualified name ecomm:partners, partners is the local name and ecomm is the prefix:

         <ecomm:business id="soda_shop" type="brick_n_mortar">
         <ecomm:partners>
         <ecomm:partner id="1001">Tony's Syrup Warehouse</ecomm:partner>
         </ecomm:partners>
         </ecomm:business>

For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as document.createElement, localName is always null.


Implementation
    public function get localName():DOMString

See also


Example
(Must be served with XML content type, such as text/xml or application/xhtml+xml.)
         <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:svg="http://www.w3.org/2000/svg">
         <head>
             <script type="application/javascript"><![CDATA[
             function test() {
                 var text = document.getElementById('text');
                 var circle = document.getElementById('circle');
         
                 text.value = "<svg:circle> has:\n" +
                     "localName = '" + circle.localName + "'\n" +
                     "namespaceURI = '" + circle.namespaceURI + "'";
                 }
             ]]></script>
         </head>
         <body onload="test()">
         
             <svg:svg version="1.1"
                 width="100px" height="100px"
                 viewBox="0 0 100 100">
                 <svg:circle cx="50" cy="50" r="30" style="fill:#aaa" id="circle"/>
             </svg:svg>
             <textarea id="text" rows="4" cols="55"/>
         </body>
         </html>
DOM 2 Core namespaceURIproperty 
namespaceURI:DOMString  [read-only]

Introduced in: DOM 2 Core 

The namespace URI of the node, or null if it is unspecified (read-only). When the node is a document, it returns the XML namespace for the current document.

Note: This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.

Note: For nodes of any nodeType other than ELEMENT_NODE and ATTRIBUTE_NODE, and nodes created with a DOM Level 1 method, such as document.createElement, the value of namespaceURI is always null.

Note: You can create an element with the specified namespaceURI using the DOM Level 2 method document.createElementNS.

Note: Per the Namespaces in XML specification, an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it has no namespace.

Note: The DOM does not handle or enforce namespace validation per se. It is up to the DOM application to do any validation necessary. Note too that the namespace prefix, once it is associated with a particular node, cannot be changed.


Implementation
    public function get namespaceURI():DOMString

See also


Example
In this snippet, a node is being examined for its localName and its namespaceURI. If the namespaceURI returns the XUL namespace and the localName returns "browser", then the node is understood to be a XUL <browser/>.
         if (node.localName == "browser" && 
             node.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul") {
             // this is a XUL browser 
         }
DOM 1 Core nextSiblingproperty 
nextSibling:Node  [read-only]

Introduced in: DOM 1 Core 

Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list.

Note (Mozilla): Gecko-based browsers insert text nodes into a document to represent whitespace in the source markup. Therefore a node obtained for example via firstChild or previousSibling may refer to a whitespace text node, rather than the actual element the author intended to get.


Implementation
    public function get nextSibling():Node

See also


Example
         <div id="div-01">Here is div-01</div>
         <div id="div-02">Here is div-02</div>
         
         <script type="text/javascript">
             var el = document.getElementById('div-01').nextSibling;
             document.write('<p>Siblings of div-01</p><ol>');
             while (el) {
                 document.write('<li>' + el.nodeName + '</li>');
                 el = el.nextSibling;
             }
             document.write('</ol>');
         </script>
         
         /**************************************************
             The following is written to the page as it loads:
         
                 Siblings of div-01
         
                 1. #text
                 2. DIV
                 3. #text
                 4. SCRIPT
                 5. P
                 6. OL
         **************************************************/
         
In the above example, it can be seen that #text nodes are inserted in the DOM where whitespace occurs in the markup between tags (i.e. after the closing tag of an element and before the opening tag of the next). No whitespace is created between the elements inserted by the document.write statement.

The possible inclusion of text nodes in the DOM must be allowed for when traversing the DOM using nextSibling. See the resources in the Notes section.

DOM 1 Core nodeNameproperty 
nodeName:DOMString  [read-only]

Introduced in: DOM 1 Core 

Returns the name of the current node as a string.

Note: Here are the returned values for different types of nodes:

InterfacenodeName
Attrsame as Attr.name
CDATASection"#cdata-section"
Comment"#comment"
Document"#document"
DocumentFragment"#document-fragment"
DocumentTypesame as DocumentType.name
Elementsame as Element.tagName
Entityentity name
EntityReferencename of entity reference
Notationnotation name
ProcessingInstructionsame as ProcessingInstruction.target
text"#text"


Implementation
    public function get nodeName():DOMString

See also


Example
Given the following markup:
         <div id="d1">hello world</div>
         <input type="text" id="t"/>

and the following script:

         var div1 = document.getElementById("d1");
         var text_field = document.getElementById("t"); 
         text_field.value = div1.nodeName;

In XHTML (or any other XML format), text_field's value would read "div". However, in HTML, text_field's value would read "DIV".

Note that tagName property could have been used instead, since nodeName has the same value as tagName for an element. Bear in mind, however, that nodeName will return #text for text nodes while tagName will return undefined.

nodePrincipalproperty 
nodePrincipal:nsIPrincipal  [read-only]

Non-standard (Mozilla)

Returns the nsIPrincipal object representing current security context of the node.

Note: This property exists on all nodes (HTML, XUL, SVG, MathML, etc.), but only if the script trying to use it has UniversalXPConnect privileges.


Implementation
    public function get nodePrincipal():nsIPrincipal

See also

DOM 1 Core nodeTypeproperty 
nodeType:Number  [read-only]

Introduced in: DOM 1 Core 

Returns an integer code representing the type of the node.


Implementation
    public function get nodeType():Number

See also


Example
This example checks if the first node inside the document element is a comment node, and if it is not, displays a message.
         var node = document.documentElement.firstChild;
         if(node.nodeType != Node.COMMENT_NODE)
         alert("You should comment your code well!");
nodeTypedValueproperty 
nodeTypedValue:*

Non-standard (Microsoft)

Contains the node value expressed in its defined data type.

Note: This value depends on the value of the nodeType property of the IXMLDOMNode.

Note: The data type for this node is defined in its dataType Property. This property also depends on the value of the node type, in the nodeType property.

Note: Although you can explicitly set the nodeTypedValue property with a particular data type in the VARIANT, the set operation does not change the data type. The value in the VARIANT is coerced to the data type specified in the dataType property, and the set operation returns an error if the type coercion is not possible.

ValueDescription
NODE_ATTRIBUTEReturns the value in the data representation of the type specified in the schema for the attribute. (Data types are specified using the dt:dt attribute, and because attributes cannot be applied to attributes, the attribute's data type can be specified only in the schema.) If no type was specified, returns a string identical to the nodeValue property. If the new value is not of the type specified in the schema or cannot be coerced to the type specified in the schema, then an error occurs.
NODE_CDATA_SECTION, NODE_COMMENT, NODE_DOCUMENT, NODE_DOCUMENT_FRAGMENT, NODE_DOCUMENT_TYPE, NODE_ENTITY, NODE_NOTATION, NODE_PROCESSING_INSTRUCTIONReturns a string that is equal to the nodeValue property. These node types do not have data types.
NODE_ELEMENTeturns the value in the data representation of the type specified on the element instance (using the dt:dt attribute) or specified in the schema. If no type was specified on the instance or in the schema, returns a string identical to the nodeValue property. If the element has an attribute data type, returns null.
NODE_ENTITY_REFERENCEReturns the value in the data representation of the type specified for the referenced entity. This is limited to entities with a single data type on the root level element of the subtree corresponding to the entity. If no data type was specified, returns a string identical to the nodeValue property.
NODE_TEXTReturns the value in the data representation of the type of the containing element. If the containing element was not typed, returns a string identical to the nodeValue property.

Data Type Mapping

VARIANT returnedCorresponding element data type
VT_BSTRstring
VT_BSTRnumber
VT_I4Int
VT_CYFixed.14.4
VT_BOOLBoolean
VT_DATEdateTime
VT_DATEdateTime.tz
VT_DATEDate
VT_DATETime
VT_DATETime.tz
VT_I1i1 byte
VT_I2i2
VT_I4i4, int
VT_UI1ui1
VT_UI2ui2
VT_UI4ui4
VT_FLOATr4
VT_DOUBLEr8, float
VT_BSTRuuid
VT_ARRAYbin.hex
VT_ARRAYbin.base64


Implementation
    public function get nodeTypedValue():*
    public function set nodeTypedValue(value:any):void

See also

nodeTypeStringproperty 
nodeTypeString:DOMString  [read-only]

Non-standard (Microsoft)

Returns the node type in string form.


Implementation
    public function get nodeTypeString():DOMString

See also


Example
This value depends on the value of the nodeType property.
NODE_ATTRIBUTE == "attribute"
DOM 1 Core nodeValueproperty 
nodeValue:DOMString

Introduced in: DOM 1 Core 

Returns or sets the value of the current node.

Note: For the document itself, nodeValue returns null. For text, comment, and CDATA nodes, nodeValue returns the content of the node. For attribute nodes, the value of the attribute is returned.

Note: The following table shows the return values for different elements:

InterfacenodeValue
Attrvalue of attribute
CDATASectioncontent of the CDATA Section
Commentcontent of the comment
Documentnull
DocumentFragmentnull
DocumentTypenull
Elementnull
Entitynull
EntityReferencenull
Notationnull
ProcessingInstructionentire content excluding the target
textcontent of the text node

Note: When nodeValue is defined to be null, setting it has no effect.


Implementation
    public function get nodeValue():DOMString
    public function set nodeValue(value:DOMString):void

Throws
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
 
DOMException — DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

See also

DOM 1 Core ownerDocumentproperty 
ownerDocument:Document  [read-only]

Introduced in: DOM 1 Core 
Modified in: DOM 2 Core 

The Document object associated with this node. This is also the Document object used to create new nodes.

Note: When this node is a Document or a DocumentType which is not used with any Document yet, this is null.


Implementation
    public function get ownerDocument():Document

See also


Example
         // given a node "p", get the top-level HTML child 
         // of the document object
         d = p.ownerDocument; 
         html = d.documentElement;
DOM 1 Core parentNodeproperty 
parentNode:Node  [read-only]

Introduced in: DOM 1 Core 

Returns the parent of the specified node in the DOM tree.

Note: parentNode returns null for the following node types: Attr, Document, DocumentFragment, Entity, and Notation.

Note: It also returns null if the node has just been created and is not yet attached to the tree.


Implementation
    public function get parentNode():Node

See also


Example
         if (node.parentNode) {
             // remove a node from the tree, unless it's not in the tree already
             node.parentNode.removeChild(node);
         }
parsedproperty 
parsed:Boolean  [read-only]

Non-standard (Microsoft)

Indicates the parsed status of the node and child nodes.

Note: During asynchronous access, not all of the document tree may be available. Before performing some operations, such as Extensible Stylesheet Language Transformations (XSLT) or pattern-matching operations, it is useful to know whether the entire tree below this node is available for processing.


Implementation
    public function get parsed():Boolean

See also

DOM 2 Core prefixproperty 
prefix:DOMString

Introduced in: DOM 2 Core 

Returns the namespace prefix of the specified node, or null if no prefix is specified.

Note: This will only work when a namespace-aware parser is used, i.e. when a document is served with an XML mime-type. This will not work for HTML documents.


Implementation
    public function get prefix():DOMString
    public function set prefix(value:DOMString):void

Throws
DOMException — INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character according to the XML version in use specified in the Document.xmlVersion attribute.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 
DOMException — NAMESPACE_ERR: Raised if the specified prefix is malformed per the Namespaces in XML specification, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" [XML Namespaces].

See also


Example
The following alerts "x".
<x:div onclick="alert(this.prefix)"/>
DOM 1 Core previousSiblingproperty 
previousSibling:Node  [read-only]

Introduced in: DOM 1 Core 

Returns the node immediately preceding the specified one in its parent's childNodes list, null if the specified node is the first in that list.

Note (Mozilla): Gecko-based browsers insert text nodes into a document to represent whitespace in the source markup. Therefore a node obtained for example via firstChild or previousSibling may refer to a whitespace text node, rather than the actual element the author intended to get.

Note: To navigate the opposite way through the child nodes list use element.nextSibling.


Implementation
    public function get previousSibling():Node

See also


Example
         // <a><b1 id="b1"/><b2 id="b2"/></a>
         alert(document.getElementById("b1").previousSibling); // null
         alert(document.getElementById("b2").previousSibling.id); // "b1"
specifiedproperty 
specified:Boolean  [read-only]

Non-standard (Microsoft)

Indicates whether the node (usually an attribute) is explicitly specified or derived from a default value in the document type definition (DTD) or schema.

Only returns true for attribute nodes if the attribute was specified directly on the element. Returns false for default attributes and all other node types.


Implementation
    public function get specified():Boolean

See also

textproperty 
text:DOMString

Non-standard (Microsoft)

Represents the text content of the node or the concatenated text representing the node and its descendants.

ValueDescription
NODE_ATTRIBUTE, NODE_DOCUMENT, NODE_ENTITYReturns a string representing the value of the node. This is the concatenated text of all subnodes with entities expanded.
NODE_CDATA_SECTION, NODE_COMMENT, NODE_PROCESSING_INSTRUCTION, NODE_TEXTReturns the text contained in the node, which is the same as the nodeValue property.
NODE_DOCUMENT_TYPE, NODE_NOTATIONReturns the empty string (""). These node types do not have associated text.
NODE_DOCUMENT_FRAGMENTReturns the text comprised of the concatenation of all descendant nodes.
NODE_ELEMENTContains a string that represents the element content. Note that this will also include the text content from all child elements, concatenated in document order. For example, consider the following XML:
<count>
  <item>one</item>
  <item>two</item>
  <item>three</item>

  <item>four</item>
</count>
                     
The text property for the <count> element contains the value "one two three four".
NODE_ENTITY_REFERENCEReturns the string representation of the entity reference.

Note: When concatenated, the text represents the contents of text or CDATA nodes. All concatenated text nodes are normalized according to xml:space attributes and the value of the preserveWhiteSpace switch. Concatenated CDATA text is not normalized. (Child nodes that contain NODE_COMMENT and NODE_PROCESSING_INSTRUCTION nodes are not concatenated.)

Note: Retrieves and sets the string representing the text contents of this node or the concatenated text representing this node and its descendants.

Note: For more precise control over text manipulation in an XML document, use the lower-level nodeValue property, which returns the raw text associated with a NODE_TEXT node.


Implementation
    public function get text():DOMString
    public function set text(value:DOMString):void

See also


Example
         <root att="   123   a   <   ">
             <a>   a   a   </a>
             <!--   comment   b   -->
             <?pi   pi   c   ?>
         
             <![CDATA[   cdata   d   ]]>
             e   f
         </root>

The text property for the root element returns the following concatenated text.

"a a   cdata   d    e f"

Note that the white space within the CDATA node is preserved.

DOM 3 Core textContentproperty 
textContent:DOMString

Introduced in: DOM 3 Core 

Gets or sets the text content of a node and its descendants.

Note: textContent returns null if the element is a document, a document type, or a notation. To grab all of the text and CDATA data for the whole document, one could usedocument.documentElement.textContent.

Note: If the node is a CDATA section, a comment, a processing instruction, or a text node, textContent returns the text inside this node (the nodeValue).

Note: For other node types, textContent returns the concatenation of the textContent attribute value of every child node, excluding comments and processing instruction nodes. This is an empty string if the node has no children.

Note: Setting this property on a node removes all of its children and replaces them with a single text node with the given value.


Implementation
    public function get textContent():DOMString
    public function set textContent(value:DOMString):void

Throws
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
 
DOMException — DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

See also


Example
         // Given the following HTML fragment:
         //   <div id="divA">This is <span>some</span> text</div>
         
         // Get the text content:
         var text = document.getElementById("divA").textContent;
         // |text| is set to "This is some text".
         
         // Set the text content:
         document.getElementById("divA").textContent = "This is some text";
         // The HTML for divA is now:
         //   <div id="divA">This is some text</div>
xmlproperty 
xml:DOMString  [read-only]

Non-standard (Microsoft)

Contains the XML representation of the node and all its descendants.

Note: The xml property always returns a Unicode string. That is, the xml property for DOMDocument converts the document from its original encoding to Unicode. As a result, the original encoding attribute is removed. For example, <?xml version="1.0" encoding="UTF-8"?> appears in the xml property as follows.

<?xml version="1.0"?>

If the original encoding was not removed by the xml property, the following line returns an error indicating the parser cannot switch from Unicode to UTF-8 encoding.

xmlDoc.loadxml(xmlDoc.xml);

If you use the save Method, the original encoding is preserved. For example, if you load a document in Microsoft® Windows® 1252 encoding, it will be saved in that format.


Implementation
    public function get xml():DOMString

See also

Method Detail
DOM 2 Events addEventListener()method
public function addEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void

Introduced in: DOM 2 Events 

Associates a function with a particular event and binds the event to the current node.

Parameters

type:DOMString — A string representing the event to bind, without the "on" prefix. For example, "click", "mousedown" etc.
 
listener:EventListener — The function or method to associate with the event.
 
useCapture:Boolean — Whether to bind the event as it is propagating towards the target node, (event Capture), or as the event bubbles upwards from the target (event bubble). Set to true or false, respectively.

See also


Example
         function statusreport() {
                 alert("document has loaded");
         }
         
         if (window.addEventListener) {
                 window.addEventListener("load", statusreport, false); //invoke function
         }
         window.onload = statusreport(); //function invoked again, since no event handler conflicts
DOM 3 Events addEventListenerNS()method 
public function addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void

Introduced in: DOM 3 Events 

Registers an event listener, depending on the useCapture parameter, on the capture phase of the DOM event flow or its target and bubbling phases.

Parameters

namespaceURI:DOMString — Specifies the Event.namespaceURI associated with the event for which the user is registering.
 
type:DOMString — A string representing the event to bind, without the "on" prefix. For example, "click", "mousedown" etc.
 
listener:EventListener — The function or method to associate with the event.
 
useCapture:Boolean — Whether to bind the event as it is propagating towards the target node, (event Capture), or as the event bubbles upwards from the target (event bubble). Set to true or false, respectively.

See also

DOM 1 Core appendChild()method 
public function appendChild(element:Node):Node

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

Adds a node to the end of the list of children of a specified parent node. If the node already exists it is removed from current parent node, then added to new parent node.

Note: If child is a reference to an existing node in the document, appendChild moves it from its current position to the new position (i.e. there is no requirement to remove the node from its parent node before appending it to some other node).

Note: This also means that a node can't be in two points of the document simultaneously. So if the node already has a parent, it is first removed, then appended at the new position.

Note: You can use cloneNode to make a copy of the node before appending it under the new parent. (Note that the copies made with cloneNode will not be automatically kept in sync.)

Note: This method is not allowed to move nodes between different documents. If you want to append node from a different document (for example to display results from AJAX request) you must first use importNode.

Note (IE6): In Microsoft Internet Explorer 6, This method now applies to the attribute object.

Note: When inserting a node tree under another node that has a different owner document, the ownerDocument property for each inserted node is changed to match the owner document of its new parent.

Note: When moving a node tree to another document, the content of all entity reference nodes contained therein is updated to conform to the new document. If the new document does not declare an entity that was moved into it, the entity reference will have no children, and the old content is removed. Existing references to nodes under the entity reference are still valid, but the node whose parent previously was the entity reference now has a null parent.

Parameters

element:Node — Object that specifies the element to append.

Returns
Node — Returns a reference to the element that is appended to the object.

Throws
DOMException — HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to append a second DocumentType or Element node.
 
DOMException — WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly.
 
DOMException — NOT_SUPPORTED_ERR: if the newChild node is a child of the Document node, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType child or Element child.

See also


Example
         // Create a new paragraph element, and append it to the end of the document body
         var p = document.createElement("p");
         document.body.appendChild(p);
DOM 1 Core cloneNode()method 
public function cloneNode(cloneChildren:Boolean):Node

Introduced in: DOM 1 Core 

Returns a duplicate of the current node.

Note: Cloning a node copies all of its attributes and their values.

Note: The duplicate node returned by cloneNode is not part of the document until it is added to another node that is part of the document using appendChild or a similar method. It also has no parent until it is appended to another node.

Note: If cloneChildren is set to false, none of the child nodes are cloned. Any text that the node contains is not cloned either, as it is contained in one or more child Text nodes.

Note: When you refer to the ID of a cloned element, a collection is returned.

Note: To clone a node for appending to a different document, use importNode instead.

Note (IE): If the node is the DOMDocument node, it is safer to clone the document using the save method, as follows. doc.save(doc2);

Parameters

cloneChildren:Boolean — FALSE, cloned objects do not include childNodes. TRUE, cloned objects include childNodes.

Returns
Node — Returns a reference to the newly created node.

See also


Example
         p = document.getElementById("para1"); 
         p_prime = p.cloneNode(true);
DOM 3 Core compareDocumentPosition()method 
public function compareDocumentPosition(other:Node):Number

Introduced in: DOM 3 Core 

Compares the position of the current node against another node in any other document.

Parameters

other:Node — The node that's being compared against.

Returns
Number — The return value is computed as the relationship that otherNode has

Throws
DOMException — NOT_SUPPORTED_ERR: when the compared nodes are from different DOM implementations that do not coordinate to return consistent implementation-specific results.

See also


Example
         var head = document.getElementsByTagName('head').item(0);
         var result = head.compareDocumentPosition(document.body);
         // result = Node.DOCUMENT_POSITION_FOLLOWING
DOM 2 Events dispatchEvent()method 
public function dispatchEvent(evt:Event):Boolean

Introduced in: DOM 2 Events 
Modified in: DOM 3 Events 

Dispatches an event to fire on a node artificially.

Note (IE): IE's equivalent of dispatchEvent() is fireEvent().

Parameters

evt:Event — The event to be dispatched.

Returns
Boolean — Indicates whether any of the listeners which handled the event called Event.preventDefault(). If Event.preventDefault() was called the returned value is false, else it is true.

See also


Example
         <div id="test" onclick="alert('hi')">Sample DIV.</div>
         <script type="text/javascript">
         //Generate an artificial click event on "test". Fires alert("hi")
         var clickevent = document.createEvent("MouseEvents");
         clickevent.initEvent("click", true, true);
         document.getElementById("test").dispatchEvent(myevent);
         </script>
DOM 3 Core getFeature()method 
public function getFeature(feature:DOMString, version:DOMString):DOMObject

Introduced in: DOM 3 Core 

This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in DOM Features. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in Mixed DOM Implementations. This method also allow the implementation to provide specialized objects which do not support the Node interface.

Parameters

feature:DOMString — The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.
 
version:DOMString — This is the version number of the feature to test.

Returns
DOMObject — Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the Node interface, it must delegate to the primary core Node and not return results inconsistent with the primary core Node such as attributes, childNodes, etc.

See also

DOM 3 Core getUserData()method 
public function getUserData(key:DOMString):DOMUserData

Introduced in: DOM 3 Core 

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.

Parameters

key:DOMString — The key the object is associated to.

Returns
DOMUserData — Returns the DOMUserData associated to the given key on this node, or null if there was none.

See also


Example
         var d = document.setUserData('key', 15, null);
         alert(document.getUserData('key')); // 15
DOM 2 Core hasAttributes()method 
public function hasAttributes():Boolean

Introduced in: DOM 2 Core 

Returns a boolean value of true or false, indicating if the current element has any attributes or not.

Returns
Boolean — If the current element has any attributes or not.

See also


Example
         t1 = document.getElementById("table-data"); 
         if (t1.hasAttributes()) { 
             // do something with t1.attributes
         }
 var result=document.getElementsByTagName("div")[0].hasAttributes();
DOM 1 Core hasChildNodes()method 
public function hasChildNodes():Boolean

Introduced in: DOM 1 Core 

Returns a value that indicates whether the object has children.

Note: If the object contains HTML Elements or TextNodes, they can be accessed from the childNodes collection.

Note: element.hasChildNodes, without the parenthesises, will return the hasChildNodes Function, and not a Boolean.

Note (IE6): In Microsoft Internet Explorer 6, This method now applies to the attribute object.

Returns
Boolean

See also


Example
Remove the first child node inside the element with the id "foo" if foo has child nodes.
         var foo = document.getElementById("foo");
         if (foo.hasChildNodes()) { 
             foo.removeChild(foo.childNodes[0]);
         }
DOM 1 Core insertBefore()method 
public function insertBefore(newNode:Node, childNode:Node):Node

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

Inserts the specified node before a reference element as a child of the current node.

Note: Do not specify the childNode parameter when inserting the first child node. If children already exist and you do not specify the childNode parameter, the oNewNode becomes the last child of the parent object.

Note (IE6): In Microsoft Internet Explorer 6, This method now applies to the attribute object.

Parameters

newNode:Node — The node to insert.
 
childNode:Node — The node before which newNode is inserted.

Returns
Node — Returns a reference to the element that is inserted into the document.

Throws
DOMException — HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to insert a second DocumentType or Element node.
 
DOMException — WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
 
DOMException — NOT_FOUND_ERR: Raised if refChild is not a child of this node.
 
DOMException — NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the insertion of a DocumentType or Element node.

See also


Example
          <html>
         
         <head>
             <title>Gecko DOM insertBefore test</title>
         </head>
         
         <body>
         
         <div>
             <span id="childSpan">foo bar</span>
         </div>
         
         <script type="text/javascript">
             // create an empty element node
             // without an ID, any attributes, or any content
             var sp1 = document.createElement("span");
         
             // give it an id attribute called 'newSpan'
             sp1.setAttribute("id", "newSpan");
         
             // create some content for the newly created element.
             var sp1_content = document.createTextNode("This is a new span element. ");
         
             // apply that content to the new element
             sp1.appendChild(sp1_content);
         
             var sp2 = document.getElementById("childSpan");
             var parentDiv = sp2.parentNode;
         
             // insert the new element into the DOM before sp2
             parentDiv.insertBefore(sp1, sp2);
         </script>
         
         </body>
         </html>

There is no insertAfter method, however it can be emulated using a combination of insertBefore and nextSibling.

From the above example, sp1 could be inserted after sp2 using:

parentDiv.insertBefore(sp1, sp2.nextSibling);

If sp2 does not have a next sibling it must be the last child—sp2.nextSibling will return null so sp1 will be inserted at the end of the child nodes list (i.e. immediately after sp2).

DOM 3 Core isDefaultNamespace()method 
public function isDefaultNamespace(namespaceURI:DOMString):Boolean

Introduced in: DOM 3 Core 

Returns true if the namespace is the default namespace on the given node or false if not.

Parameters

namespaceURI:DOMString — The namespace against which the element will be checked.

Returns
Boolean — If the namespace is the default namespace on the given node or false if not.

See also


Example
         var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
         var el = document.getElementsByTagNameNS(XULNS, 'textbox')[0];
         alert(el.isDefaultNamespace(XULNS)); // true
DOM 3 Core isEqualNode()method 
public function isEqualNode(arg:Node):Boolean

Introduced in: DOM 3 Core 

Tests whether two nodes are equal.

This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true. Two nodes are equal if and only if the following conditions are satisfied:

For two DocumentType nodes to be equal, the following conditions must also be satisfied:

On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.

Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.

Parameters

arg:Node — The node to compare equality with.

Returns
Boolean — Returns true if the nodes are equal, false otherwise.

See also

DOM 3 Core isSameNode()method 
public function isSameNode(other:Node):Boolean

Introduced in: DOM 3 Core 

Returns whether this node is the same node as the given one. This method provides a way to determine whether two Node references returned by the implementation reference the same object. When two Node references are references to the same object, even if through a proxy, the references may be used completely interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.

Parameters

other:Node — The node to test against.

Returns
Boolean — Returns true if the nodes are the same, false otherwise.

See also

DOM 2 Core isSupported()method 
public function isSupported(feature:DOMString, version:DOMString):Boolean

Introduced in: DOM 2 Core 

Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Note: To check if any version of the DOM specification is supported, you can pass in null as the version instead of a string.

Parameters

feature:DOMString — name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation. Possible values defined within the core DOM specification are listed on the DOM Level 2 Conformance Section. The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation. Possible values defined within the core DOM specification are listed on the DOM Level 2 Conformance Section.
 
version:DOMString — This is the version number of the feature to test. In DOM Level 2, version 1, this is the string 2.0. If the version is not specified, supporting any version of the feature will cause the method to return true.

Returns
Boolean

See also


Example
         // Get an element and check to see if its supports the DOM2 HTML Module
         <div id="doc">
         </div>
         var main = document.getElementById('doc');
         var output = main.isSupported('HTML', '2.0');
DOM 3 Core lookupNamespaceURI()method 
public function lookupNamespaceURI(prefix:DOMString):DOMString

Introduced in: DOM 3 Core 

Takes a prefix and returns the namespaceURI associated with it on the given node if found (and null if not). Supplying null for the prefix will return the default namespace.

Note (Mozilla): Due to bug 312019, this method does not work with dynamically assigned namespaces (i.e., those set with Node.prefix).

Parameters

prefix:DOMString — The prefix to look for. If this parameter is null, the method will return the default namespace URI if any.

Returns
DOMString — Returns the associated namespace URI or null if none is found.

See also

DOM 3 Core lookupPrefix()method 
public function lookupPrefix(namespaceURI:DOMString):DOMString

Introduced in: DOM 3 Core 

Returns the prefix for a given namespaceURI if present, and null if not. When multiple prefixes are possible, the result is implementation-dependent.

Note (Mozilla): Due to bug 312019, this method does not work with dynamically assigned namespaces (i.e., those set with Node.prefix).

Parameters

namespaceURI:DOMString — The namespace URI to look for.

Returns
DOMString — Returns an associated namespace prefix if found or null if none is found. If more than one prefix are associated to the namespace prefix, the returned namespace prefix is implementation dependent.

See also

DOM 1 Core normalize()method 
public function normalize():void

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

Puts the specified node and all of its subtree into a "normalized" form. In a normalized subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.

Note (IE): By calling object.normalize before the subelements of an object are manipulated, you ensure that the document object model has a consistent structure. The normal form is useful for operations that require a consistent document tree structure, and it ensures that the document object model view is identical when saved and reloaded.

Note (IE): Adjacent CDATA sections will not be merged by the normalize method, allowing for an inconsistent object model when CDATA sections are present.

See also

DOM 1 Core removeChild()method 
public function removeChild(node:Node):Node

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

Removes a child node from the object.

The node to be removed must be an immediate child of the parent object.

If child is actually not a child of the element node, the method throws an exception.

Note: The removed child node still exists in memory, but is no longer part of the DOM. You may reuse the removed node later in your code, via the oldChild object reference.

Note (IE6): In Microsoft Internet Explorer 6, This method now applies to the attribute object.

Parameters

node:Node — Specifies the element to be removed from the document.

Returns
Node — Returns a reference to the object that is removed.

Throws
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 
DOMException — NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
 
DOMException — NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType child or the Element child.

See also


Example
         // <div id="top" align="center">
         //   <div id="nested"></div> 
         // </div>
         
         var d = document.getElementById("top"); 
         var d_nested = document.getElementById("nested"); 
         var throwawayNode = d.removeChild(d_nested);
         // remove all children from element
         var element = document.getElementById("top");
         while (element.firstChild) {
             element.removeChild(element.firstChild);
         }
DOM 2 Events removeEventListener()method 
public function removeEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void

Introduced in: DOM 2 Events 

Removes an event listener.

Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect. The Event.namespaceURI for which the user registered the event listener is implied and is null.

Parameters

type:DOMString — Specifies the Event.type for which the user registered the event listener.
 
listener:EventListener — The EventListener to be removed.
 
useCapture:Boolean — Specifies whether the EventListener being removed was registered for the capture phase or not. If a listener was registered twice, once for the capture phase and once for the target and bubbling phases, each must be removed separately. Removal of an event listener registered for the capture phase does not affect the same event listener registered for the target and bubbling phases, and vice versa.

See also

DOM 3 Events removeEventListenerNS()method 
public function removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void

Introduced in: DOM 3 Events 

Removes an event listener. Calling removeEventListenerNS with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.

Parameters

namespaceURI:DOMString — Specifies the Event.namespaceURI associated with the event for which the user registered the event listener.
 
type:DOMString — Specifies the Event.type for which the user registered the event listener.
 
listener:EventListener — The EventListener to be removed.
 
useCapture:Boolean — Specifies whether the EventListener being removed was registered for the capture phase or not. If a listener was registered twice, once for the capture phase and once for the target and bubbling phases, each must be removed separately. Removal of an event listener registered for the capture phase does not affect the same event listener registered for the target and bubbling phases, and vice versa.

See also

DOM 1 Core replaceChild()method 
public function replaceChild(newNode:Node, childNode:Node):Node

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

Replaces an existing child element with a new child element.

Parameters

newNode:Node — The new node to replace oldChild. If it already exists in the DOM, it is first removed.
 
childNode:Node — Specifies the existing element to be replaced.

Returns
Node — Returns a reference to the object that is replaced.

Throws
DOMException — HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors or this node itself, or if this node is of type Document and the result of the replacement operation would add a second DocumentType or Element on the Document node.
 
DOMException — WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
 
DOMException — NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
 
DOMException — NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the replacement of the DocumentType child or Element child.

See also


Example
         // <div>
         //  <span id="childSpan">foo bar</span>
         // </div>
         
         // create an empty element node
         // without an ID, any attributes, or any content
         var sp1 = document.createElement("span");
         
         // give it an id attribute called 'newSpan'
         sp1.setAttribute("id", "newSpan");
         
         // create some content for the new element.
         var sp1_content = document.createTextNode("new replacement span element.");
         
         // apply that content to the new element
         sp1.appendChild(sp1_content);
         
         // build a reference to the existing node to be replaced
         var sp2 = document.getElementById("childSpan");
         var parentDiv = sp2.parentNode;
         
         // replace existing node sp2 with the new span element sp1
         parentDiv.replaceChild(sp1, sp2);
selectNodes()method 
public function selectNodes(queryString:DOMString):NodeList

Non-standard (Microsoft)

Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as IXMLDOMNodeList.

Note (IE): This method is only valid if the XML Query Language (XQL) feature has been included in the operating system (OS). If a call to this method is made and XQL is not supported, an error message will be returned.

Note (IE): The selectSingleNode method is similar to the selectNodes method, but returns only the first matching node rather than the list of all matching nodes.

Parameters

queryString:DOMString — A XSLPattern or XPath query that is to be applied to the context defined by this node. The value of the SelectionLanguage internal property (flag) determines whether an XSLPattern or XPath query is used. By default, the queryString is an XSLPattern query. The SelectionLanguage internal property (flag) can be set with the setProperty Method.

Returns
NodeList — Returns a collection of nodes selected by an XSL Pattern or XPath query. If no nodes are selected, an empty collection is returned.

See also

selectSingleNode()method 
public function selectSingleNode(queryString:DOMString):Node

Non-standard (Microsoft)

Applies the specified pattern-matching operation to this node's context and returns the first matching node.

Note (IE): This method is only valid if the XML Query Language (XQL) feature has been included in the OS. If a call to this method is made and XQL is not supported, an error message will be returned.

Note (IE): The selectSingleNode method is similar to the selectNodes Method, but returns only the first matching node rather than the list of all matching nodes.

Parameters

queryString:DOMString — A Extensible Stylesheet Language (XSL) or XPath query that is to be applied to the context defined by this node. The value of the SelectionLanguage internal property (flag) determines whether an XSL or XPath query is used. By default, the expression is an XSL pattern query. The SelectionLanguage internal property (flag) can be set with the setProperty method.

Returns
Node — Returns the first node that matches the XSL or XPath query. If no nodes match the query, it returns Null.

See also

DOM 3 Core setUserData()method 
public function setUserData(key:DOMString, data:DOMUserData, handler:UserDataHandler):DOMUserData

Introduced in: DOM 3 Core 

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.

Allows a user to attach data to an element, without needing to modify the DOM. Note that such data will not be preserved when imported via importNode, as with cloneNode() and renameNode() operations (though adoptNode does preserve the information), and equality tests in isEqualNode() do not consider user data in making the assessment.

This method offers the convenience of associating data with specific nodes without needing to alter the structure of a document and in a standard fashion, but it also means that extra steps may need to be taken if one wishes to serialize the information or include the information upon clone, import, or rename operations.

Parameters

key:DOMString — The key to associate the object to.
 
data:DOMUserData — The object to associate to the given key, or null to remove any existing association to that key.
 
handler:UserDataHandler — The handler to associate to that key, or null.

Returns
DOMUserData — Returns the DOMUserData previously associated to the given key on this node, or null if there was none.

See also


Example
         var d = document.implementation.createDocument('', 'test', null); 
         d.documentElement.setUserData('key', 15, {handle:function (o, k, d, s, ds) {alert(o+'::'+k+'::'+d+'::'+s+'::'+ds)}}); // 2::key::15::[object Element]::[object Element]
         alert(d.documentElement.getUserData('key')); // 15
         var e = document.importNode(d.documentElement, true); // causes handler to be called
         alert(e.getUserData('key')); // null since user data is not copied
transformNode()method 
public function transformNode(styleSheet:Node):DOMString

Non-standard (Microsoft)

Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.

Note (IE): This method is only valid if the XSLT feature has been included in the operating system (OS). If a call to this method is made and XSLT is not supported, an error message will be returned.

Note (IE): The stylesheet parameter must be either a DOMDocument node, in which case the document is assumed to be an Extensible Stylesheet Language (XSL) style sheet, or a Document Object Model (DOM) node in the XSL style sheet, in which case this node is treated as a stand-alone style sheet fragment.

Note (IE): The source node defines a context in which the style sheet operates, but navigation outside this scope is allowed. For example, a style sheet can use the id function to access other parts of the document.

Note (IE): This method supports both stand-alone and embedded style sheets and also provides the ability to run a localized style sheet fragment against a particular source node.

Parameters

styleSheet:Node — Valid XML document or DOM node that consists of XSLT elements that direct the transformation of this node.

Returns
DOMString — Returns a string that contains the product of the transformation of this XML document based on the XSLT style sheet.

See also

transformNodeToObject()method 
public function transformNodeToObject(styleSheet:Node, outputObject:*):void

Non-standard (Microsoft)

Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.

Note (IE): This method is only valid if the XSLT feature has been included in the operating system (OS). If a call to this method is made and XSLT is not supported, an error message will be returned.

Note (IE): The stylesheet parameter must be either a DOMDocument node, in which case the document is assumed to be an XSLT style sheet, or a Document Object Model (DOM) node in the XSLT style sheet, in which case this node is treated as a stand-alone style sheet fragment.

Note (IE): The source node defines a context in which the style sheet operates, but navigation outside this scope is allowed. For example, a style sheet can use the id function to access other parts of the document.

Note (IE): This method supports both stand-alone and embedded style sheets and also provides the ability to run a localized style sheet fragment against a particular source node.

Note (IE): The transformNodeToObject method always generates a Unicode byte-order mark, which means it cannot be used in conjunction with other Active Server Pages (ASP) Response.Write or Response.BinaryWrite calls.

Parameters

styleSheet:Node — Valid XML document or DOM node that consists of XSLT elements that direct the transformation of this node.
 
outputObject:* — On return, contains the product of the transformation of this XML document based on the XSLT style sheet. If the variant represents the DOMDocument object, the document is built according to its properties and its child nodes are replaced during this transformation process. The XML transformation can also be sent to a stream.

See also

Constant Detail
DOM 1 Core ATTRIBUTE_NODEConstant
public static const ATTRIBUTE_NODE:Number = 2

Introduced in: DOM 1 Core 

The node is an Attr.

The node represents an attribute of an element. An attribute node can have the following child node types: Text and EntityReference. An attribute does not appear as the child node of any other node type; note that it is not considered a child node of an element.

See also

DOM 1 Core CDATA_SECTION_NODEConstant 
public static const CDATA_SECTION_NODE:Number = 4

Introduced in: DOM 1 Core 

The node is a CDATASection.

The node represents a CDATA section in the XML source. CDATA sections are used to escape blocks of text that would otherwise be recognized as markup. A CDATA section node cannot have any child nodes. A CDATA section node can appear as the child of the DocumentFragment, EntityReference, and Element nodes.

See also

DOM 1 Core COMMENT_NODEConstant 
public static const COMMENT_NODE:Number = 8

Introduced in: DOM 1 Core 

The node is a Comment.

The node represents a comment in the XML document. A comment node cannot have any child nodes. A comment node can appear as the child of Document, DocumentFragment, Element, and EntityReference nodes.

See also

DOM 1 Core DOCUMENT_FRAGMENT_NODEConstant 
public static const DOCUMENT_FRAGMENT_NODE:Number = 11

Introduced in: DOM 1 Core 

The node is a DocumentFragment.

The node represents a document fragment. A document fragment node associates a node or subtree with a document without actually being contained within the document. A document fragment node can have the following child node types: Element, ProcessingInstruction, Comment, Text, CDATASection, and EntityReference. A DocumentFragment node cannot appear as the child of any node types.

See also

DOM 1 Core DOCUMENT_NODEConstant 
public static const DOCUMENT_NODE:Number = 9

Introduced in: DOM 1 Core 

The node is a Document.

The node represents a document object, which, as the root of the document tree, provides access to the entire XML document. It is created using the progID "Msxml2.DOMDocument", or through a data island using <XML> or <SCRIPT LANGUAGE=XML>. A document node can have the following child node types: Element (maximum of one), ProcessingInstruction, Comment, and DocumentType. A document node cannot appear as the child of any node types.

See also

DOM 3 Core DOCUMENT_POSITION_CONTAINED_BYConstant 
public static const DOCUMENT_POSITION_CONTAINED_BY:Number = 16

Introduced in: DOM 3 Core 

The node is contained by the reference node. A node which is contained is always following, too.

See also

DOM 3 Core DOCUMENT_POSITION_CONTAINSConstant 
public static const DOCUMENT_POSITION_CONTAINS:Number = 8

Introduced in: DOM 3 Core 

The node contains the reference node. A node which contains is always preceding, too.

See also

DOM 3 Core DOCUMENT_POSITION_DISCONNECTEDConstant 
public static const DOCUMENT_POSITION_DISCONNECTED:Number = 1

Introduced in: DOM 3 Core 

The two nodes are disconnected. Order between disconnected nodes is always implementation-specific.

See also

DOM 3 Core DOCUMENT_POSITION_FOLLOWINGConstant 
public static const DOCUMENT_POSITION_FOLLOWING:Number = 4

Introduced in: DOM 3 Core 

The node follows the reference node.

See also

DOM 3 Core DOCUMENT_POSITION_IMPLEMENTATION_SPECIFICConstant 
public static const DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:Number = 32

Introduced in: DOM 3 Core 

The determination of preceding versus following is implementation-specific.

See also

DOM 3 Core DOCUMENT_POSITION_PRECEDINGConstant 
public static const DOCUMENT_POSITION_PRECEDING:Number = 2

Introduced in: DOM 3 Core 

The second node precedes the reference node.

See also

DOM 1 Core DOCUMENT_TYPE_NODEConstant 
public static const DOCUMENT_TYPE_NODE:Number = 10

Introduced in: DOM 1 Core 

The node is a DocumentType.

The node represents the document type declaration, indicated by the <!DOCTYPE > tag. A document type node can have the following child node types: Notation and Entity. A document type node can appear as the child of the Document node.

See also

DOM 1 Core ELEMENT_NODEConstant 
public static const ELEMENT_NODE:Number = 1

Introduced in: DOM 1 Core 

The node is an Element.

The node represents an element. An element node can have the following child node types: Element, Text, Comment, ProcessingInstruction, CDATASection, and EntityReference. An element node can be the child of the Document, DocumentFragment, EntityReference, and Element nodes.

See also

DOM 1 Core ENTITY_NODEConstant 
public static const ENTITY_NODE:Number = 6

Introduced in: DOM 1 Core 

The node is an Entity.

The node represents an expanded entity. An entity node can have child nodes that represent the expanded entity (for example, Text and EntityReference nodes). An entity node can appear as the child of the DocumentType node.

See also

DOM 1 Core ENTITY_REFERENCE_NODEConstant 
public static const ENTITY_REFERENCE_NODE:Number = 5

Introduced in: DOM 1 Core 

The node is an EntityReference.

The node represents a reference to an entity in the XML document. This applies to all entities, including character entity references. An entity reference node can have the following child node types: Element, ProcessingInstruction, Comment, Text, CDATASection, and EntityReference. An entity reference node can appear as the child of the Attribute, DocumentFragment, Element, and EntityReference nodes.

See also

DOM 1 Core NOTATION_NODEConstant 
public static const NOTATION_NODE:Number = 12

Introduced in: DOM 1 Core 

The node is a Notation.

A node represents a notation in the document type declaration. A notation node cannot have any child nodes. A notation node can appear as the child of the DocumentType node.

See also

DOM 1 Core PROCESSING_INSTRUCTION_NODEConstant 
public static const PROCESSING_INSTRUCTION_NODE:Number = 7

Introduced in: DOM 1 Core 

The node is a ProcessingInstruction.

The node represents a processing instruction from the XML document. A processing instruction node cannot have any child nodes. A processing instruction node can appear as the child of the Document, DocumentFragment, Element, and EntityReference nodes.

See also

DOM 1 Core TEXT_NODEConstant 
public static const TEXT_NODE:Number = 3

Introduced in: DOM 1 Core 

The node is a Text node.

The node represents the text content of a tag. A text node cannot have any child nodes. A text node can appear as the child node of the Attribute, DocumentFragment, Element, and EntityReference nodes.

See also