Home to Document Object Model | Up to Core
Prev DOMImplementation | Next Node


NamedNodeMap
Object

Container for collections of nodes, accessible by name. (Note that, although the item method takes an integer, there is no implied ordering within the collection.) Items in the collection are "live" (effectively references to objects rather than copies of objects).

length
Attribute (read only, Number)

Specifies the range of valid index values for the item method (zero to length-1).

getNamedItem
Method
ECMAScript binding: getNamedItem(name) (returns Node; name is a string)

Returns the node with the given name or null if not found.

getNamedItemNS
Method
ECMAScript binding: getNamedItemNS(namespaceURI, localName) (returns Node; namespaceURI and localName are strings)

Introduced in DOM Level 2. Do a feature check for "XML" before blithely using this method. Returns the node with the given namespaceURI and localName or null if not found.

item
Method
ECMAScript binding: item(index) (returns Node; index is a Number)

Returns the indexth item from the collection (or null if out of range).

removeNamedItem
Method
ECMAScript binding: removeNamedItem(name) (returns Node; name is a string; can throw DOMException)

Removes the node with the given name. The node is returned.

The exceptions thrown are:

NOT_FOUND_ERR
Guess :-).
NO_MODIFICATION_ALLOWED_ERR
The node is read only.

removeNamedItemNS
Method
ECMAScript binding: removeNamedItemNS(namespaceURI, localName) (returns Node; namespaceURI and localName are string; can throw DOMException)

Introduced in DOM Level 2. Removes the node with the given namespaceURI and localName. The node is returned.

The exceptions thrown are:

NOT_FOUND_ERR
Guess :-).
NO_MODIFICATION_ALLOWED_ERR
The node is read only.

setNamedItem
Method
ECMAScript binding: setNamedItem(arg) (returns Node; arg is a Node; can throw DOMException)

If a node with a nodeName value matching arg.nodeName already exists in the map, it is removed and returned. Otherwise, null is returned. arg is then inserted into the map.

The exceptions thrown are:

WRONG_DOCUMENT_ERR
The node you're trying to insert into the map was created in another document. Don't do this.
NO_MODIFICATION_ALLOWED_ERR
The node is read only.
INUSE_ATTRIBUTE_ERR
The node is in use as an Attr on an another Element - you'll need to clone it before trying to add it here.

setNamedItemNS
Method
ECMAScript binding: setNamedItemNS(arg) (returns Node; arg is a Node; can throw DOMException)

Introduced in DOM Level 2. If a node with namespaceURI and localName values matching arg.namespaceURI and arg.localName already exists in the map, it is removed and returned. Otherwise, null is returned. arg is then inserted into the map.

The exceptions thrown are:

WRONG_DOCUMENT_ERR
The node you're trying to insert into the map was created in another document. Don't do this.
NO_MODIFICATION_ALLOWED_ERR
The node is read only.
INUSE_ATTRIBUTE_ERR
The node is in use as an Attr on an another Element - you'll need to clone it before trying to add it here.

Log in or registerto write something here or to contact authors.