NamedNodeMap — a collection of nodes indexed by name or position


DOM Level 1 Core


readonly unsigned long length

The number of nodes in the array.


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.


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 ...

Get JavaScript: The Definitive Guide, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.