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

  1. The getNamedItem(name) method retrieves a node specified by name.
  2. The getNamedItem(name) method returns a Node of any type with the specified name.
  3. The getNamedItem(name) method returns null if the specified name did not identify any node in the map.
  4. The setNamedItem(arg) method adds a node using its nodeName attribute.
  5. If a node with that name is already present in the map, it is replaced by the new one.
  6. If the setNamedItem(arg) method replaces an existing node with the same name then this method returns the previously existing node.
  7. If the setNamedItem(arg) method does not replace an already existing node then it returns null.
  8. The removeNamedItem(name) method removes a node specified by name.
  9. If the removed node is an Attr with a default value, it is immediately replaced.
  10. The removeNamedItem(name) method returns the node removed from the map.
  11. The removeNamedItem(name) method returns null if no node with such name exists.
  12. The item(index) method returns the indexth item in the map.
  13. The item(index) method returns null if index is greater than or equal to the number of nodes in the map.
  14. Atrributes

  15. The length attribute contains the number of nodes in the map.
  16. The range of valid child node indices is 0 to length - 1.
  17. DOMExceptions

  18. 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.
  19. The setNamedItem(arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if this NamedNodeMap is readonly.
  20. The setNamedItem(arg) method raises an INUSE_ATTRIBUTE_ERR DOMException if arg is an Attr that is already an attribute of another Element object.
  21. 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