6. DOM_NodeList

The DOM_NodeList type provides access to an ordered collection of nodes. The childNodes member of DOM_Node is a DOM_NodeList. The getElementsByTagName functions also return a DOM_NodeList.

The DOM recommendations specify that these lists are live meaning that modifying the children of a node should be reflected in a list returned by the getElementsByTagName functions. Currently DOMC does not update a DOM_NodeList returned by the getElementsByTagName functions if source nodes are subsequently removed or if a node is added that should be included.

Example 3. Enumerating the children of an Element
This example illustrates how to enumerate and print each comment child of a DOM_Element node.


  for (idx = 0; i < elem->childNodes->length; i++) {
  	DOM_Node *node = DOM_NodeList_item(elem->childNodes, idx);
  	if (node->nodeType == DOM_COMMENT_NODE) {
  		printf("comment: %s\n", DOM_Node_getNodeValue(node));
  	}
  }
  

6.1. The DOM_NodeList type

Synopsis


#include <domc.h> typedef struct { int length; /* other members */ } DOM_NodeList;
Description
The DOM_NodeList structure provides a length member containing the number of elements in the list. This member must never be modified.

The DOM_NodeList_item function
Synopsis

#include <domc.h> DOM_Node *DOM_NodeList_item(DOM_NodeList *this, int index);
Description
The DOM_NodeList_item function returns the node in this list at index which starts from 0.
Returns
The node at the specified index or NULL if there is no such node.


Copyright 2003 Michael B. Allen <mballen@erols.com> Generated by CStyleX 0.1.1