You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Axelle Apvrille (LMC)" <Ax...@ericsson.ca> on 2003/03/28 16:25:15 UTC

Know the exact number of children of a given node ?

Hi,
Is there a way to know the exact number of children a given node has, 
without counting the comments ?
Currently, I do:
 unsigned int count = 0;

  // retrieve the NodeList of the RULES tag.
  DOMNodeList *sr_list = getElements(RULES);

  for (int i=0; i<sr_list->getLength(); i++)
    {
      DOMNode *node = sr_list->item(i);
      if (node->hasChildNodes())
    count += node->getChildNodes()->getLength();
    }

  // do not delete sr_list (to my understanding)
  return count;


==> but comments get counted. If I have:
<rule>
<A> ... </A>
<!-- My comment -->
<B> ... </B>
</rule>
count returns 3, and not 2.
Is there a way to filter out the comments (except doing it "manually" 
reading each item) ?

Regards
Axelle.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org