NamedNodeMap Interface
The NamedNodeMap interface is used to represent a collection of nodes that can be accessed by name. The collection is not mantained in any particular order.
IDL Definition
Interface NamedNodeMap {
Node getNamedItem(in DOMString name);
Node setNamedItem(in Node arg)
raises (DOMException);
Node removeNamedItem(in DOMString name)
raises (DOMException);
Node item(in unsigned long index);
readonly attribute unsigned long length;
};
Semantic Requirements
Methods
- The getNamedItem(name) method retrieves a node specified by name.
- The getNamedItem(name) method returns a Node of any type with the specified name.
- The getNamedItem(name) method returns null if the specified name
did not identify any node in the map.
- The setNamedItem(arg) method adds a node using its nodeName attribute.
- If a node with that name is already present in the map, it is replaced by the new one.
- If the setNamedItem(arg) method replaces an existing node with the same name then this method returns the previously existing node.
- If the setNamedItem(arg) method does not replace an already existing
node then it returns null.
- The removeNamedItem(name) method removes a node specified by name.
- If the removed node is an Attr with a default value, it is immediately replaced.
- The removeNamedItem(name) method returns the node removed from the
map.
- The removeNamedItem(name) method returns null if no node
with such name exists.
- The item(index) method returns the indexth item in the map.
- The item(index) method returns null if index is greater than or equal to the number of nodes in the map.
Atrributes
- The length attribute contains the number of nodes in the map.
- The range of valid child node indices is 0 to length - 1.
DOMExceptions
- The setNamedItem(arg) method raises a WRONG_DOCUMENT_ERR DOMException if arg was created from a different document than the one that created the NamedNodeMap.
- The setNamedItem(arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if this NamedNodeMap is readonly.
- The setNamedItem(arg) method raises an INUSE_ATTRIBUTE_ERR DOMException if arg is an Attr that is already an attribute of another Element object.
- The removeNamedItem(name) raises a NOT_FOUND_ERR DOMException if there is no node named name in the map.
If you have comments or suggestions, email me at mbrady@nist.gov