DOM2 Reference
| Reference Search | Sitemap | XML Glossary |       ZVON | IDOOX

NamedNodeMap

Type of the interface: fundamental
Own properties:
attributes -  length
methods -  getNamedItem, getNamedItemNS, item, removeNamedItem, removeNamedItemNS, setNamedItem, setNamedItemNS

Description:
Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name.

Note:
Note taht NamedNodeMap objects are not maintained in any particular order and in the DOM are live.


 attribute:    NamedNodeMap.length      example  
readonly: yes
type: unsigned long
description: The number of nodes in the map. The range of valid child node indices is 0 to length-1 inclusive.


 method:    NamedNodeMap.getNamedItem(name)      example  
description: Retrieves a node specified by name.
parameters:
DOMString name  -  The nodeName of a node to retrieve.
returns:
Node  -  A Node (of any type) with the specified nodeName, or null if it does not identify any node in this map.
exceptions:  none

 method:    NamedNodeMap.getNamedItemNS(namespaceURI, localName)      example  
description: Retrieves a node specified by local name and namespace URI.
parameters:
DOMString namespaceURI  -  The namespace URI of the node to retrieve.
DOMString localName  -  The local name of the node to retrieve.
returns:
Node  -  A Node (of any type) with the specified local name and namespace URI, or null if they do not identify any node in this map.
exceptions:  none

 method:    NamedNodeMap.item(index)      example  
description: Returns the indexth item in the map. If index is greater than or equal to the number of nodes in the map, this returns null.
parameters:
unsigned long index  -  Index into this map.
returns:
Node  -  The node at the indexth position in the NamedNodeMap, or null if that is not a valid index.
exceptions:  none

 method:    NamedNodeMap.removeNamedItem(name)      example  
description: Removes a node specified by name.
parameters:
DOMString name  -  The nodeName of a node to remove.
returns:
Node  -  The node removed from this map if a node with such a name exists.
exceptions:
DOMException NOT_FOUND_ERR  -  Raised if there is no node named name in this map.
DOMException NO_MODIFICATION_ALLOWED_ERR  -  Raised if this map is readonly.
note: When this map contains the attributes attached to an element and this attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.

 method:    NamedNodeMap.removeNamedItemNS(namespaceURI, localName)      example  
description: Removes a node specified by local name and namespace URI.
parameters:
DOMString namespaceURI  -  The namespace URI of the node to remove.
DOMString localName  -  The local name of the node to remove.
returns:
Node  -  The node removed from this map if a node with such a local name and namespace URI exists.
exceptions:
DOMException NOT_FOUND_ERR  -  Raised if there is no node with the specified namespaceURI and localName in this map.
DOMException NO_MODIFICATION_ALLOWED_ERR  -  Raised if this map is readonly.
note: When this map contains the attributes attached to an element and this attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.

 method:    NamedNodeMap.setNamedItem(arg)      example  
description: Adds a node using its nodeName attribute.
parameters:
Node arg  -  A node to store in this map.
returns:
Node  -  If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
exceptions:
DOMException WRONG_DOCUMENT_ERR  -  Raised if arg was created from a different document than the one that created this map.
DOMException NO_MODIFICATION_ALLOWED_ERR  -  Raised if this map is readonly.
DOMException INUSE_ATTRIBUTE_ERR  -  Raised if arg is an Attr that is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
DOMException HIERARCHY_REQUEST_ERR  -  Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap.
note: If a node with that name is already present in this map, it is replaced by the new one.

 method:    NamedNodeMap.setNamedItemNS(arg)      example  
description: Adds a node using its namespaceURI and localName.
parameters:
Node arg  -  A node to store in this map.
returns:
Node  -  If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
exceptions:
DOMException WRONG_DOCUMENT_ERR  -  Raised if arg was created from a different document than the one that created this map.
DOMException NO_MODIFICATION_ALLOWED_ERR  -  Raised if this map is readonly.
DOMException INUSE_ATTRIBUTE_ERR  -  Raised if arg is an Attr that is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
DOMException HIERARCHY_REQUEST_ERR  -  Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap.
note: If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one.
HTML-only DOM implementations do not need to implement this method.