DekGenius.com
Team LiB   Previous Section   Next Section
NamedNodeMap a collection of nodes indexed by name or position

Availability

DOM Level 1 Core

Properties

readonly unsigned long length

The number of nodes in the array.

Methods

getNamedItem( )

Looks up a named node.

getNamedItemNS( ) [DOM Level 2]

Looks up a node specified by namespace and name.

item( )

Obtains the node at a specified position within the NamedNodeMap. In JavaScript, you can also do this by using the node position as an array index.

removeNamedItem( )

Deletes a named node from the NamedNodeMap.

removeNamedItemNS( ) [DOM Level 2]

Deletes a node specified by name and namespace from the NamedNodeMap.

setNamedItem( )

Adds a new node to (or replaces an existing node in) the NamedNodeMap. The nodeName property of the Node object is used as the name of the node.

setNamedItemNS( ) [DOM Level 2]

Adds a new node to (or replaces an existing node in) the NamedNodeMap. The namespaceURI and localName properties of the Node object are used as the node name.

Description

The NamedNodeMap interface defines a collection of nodes that may be looked up by their nodeName property or, for nodes that use namespaces, by their namespaceURI or localName properties.

The most notable use of the NamedNodeMap interface is the attributes property of the Node interface: a collection of Attr nodes that may be looked up by attribute name. Many of the methods of NamedNodeMap are similar to the methods of Element for manipulating attributes. Element attributes are usually most easily manipulated through the methods of the Element interface, and the NamedNodeMap interface is not commonly used.

NamedNodeMap objects are "live," which means that they immediately reflect any changes to the document tree. For example, if you obtain a NamedNodeMap that represents the attributes of an element and then add a new attribute to that element, the new attribute is available through the NamedNodeMap.

See Also

NodeList

Type of

DocumentType.entities, DocumentType.notations, Node.attributes

    Team LiB   Previous Section   Next Section