HTMLCollection Interface

An HTMLCollection is a list of nodes. An individual node may be accessed by either ordinal index or the nodes name or id attribute.



IDL Definition

Interface HTMLCollection {

 readonly  attribute  unsigned long            length; 
 Node                                          item(in unsigned long index);
 Node                                          namedItem(in wstring name);
};

Semantic Requirements

    Basic

  1. An individual node may be accessed by either ordinal index, node's name or id attributes.
  2. Collections in the HTML DOM are assumed to be live. They are automatically updated when the underlying document is changed.
  3. Attributes

  4. The length attribute specifies the length or size of the list.
  5. Methods

  6. The item(index) method retrieves a node specified by ordinal index.
  7. Nodes are numbered in tree order (depth-first traversal order).
  8. The item(index) method returns null if the index is out of range.
  9. The namedItem(name) method retrieves a node using a name.
  10. The namedItem(name) method first searches for a Node with a matching id attribute.
  11. If no Node with a matching id attribute is found, the namedItem(name) method then searches for a node with a matching name attribute.
  12. If no Node is found whose id or name attributes matches the specified string, the namedItem(name) method returns null.

If you have comments or suggestions, email me at mbrady@nist.gov