MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlLsCountNode

Function xmlLsCountNode

ThirdParty/libxml2/vtklibxml2/debugXML.c:1587–1632  ·  view source on GitHub ↗

* xmlLsCountNode: * @node: the node to count * * Count the children of @node. * * Returns the number of children of @node. */

Source from the content-addressed store, hash-verified

1585 * Returns the number of children of @node.
1586 */
1587int
1588xmlLsCountNode(xmlNodePtr node) {
1589 int ret = 0;
1590 xmlNodePtr list = NULL;
1591
1592 if (node == NULL)
1593 return(0);
1594
1595 switch (node->type) {
1596 case XML_ELEMENT_NODE:
1597 list = node->children;
1598 break;
1599 case XML_DOCUMENT_NODE:
1600 case XML_HTML_DOCUMENT_NODE:
1601 list = ((xmlDocPtr) node)->children;
1602 break;
1603 case XML_ATTRIBUTE_NODE:
1604 list = ((xmlAttrPtr) node)->children;
1605 break;
1606 case XML_TEXT_NODE:
1607 case XML_CDATA_SECTION_NODE:
1608 case XML_PI_NODE:
1609 case XML_COMMENT_NODE:
1610 if (node->content != NULL) {
1611 ret = xmlStrlen(node->content);
1612 }
1613 break;
1614 case XML_ENTITY_REF_NODE:
1615 case XML_DOCUMENT_TYPE_NODE:
1616 case XML_ENTITY_NODE:
1617 case XML_DOCUMENT_FRAG_NODE:
1618 case XML_NOTATION_NODE:
1619 case XML_DTD_NODE:
1620 case XML_ELEMENT_DECL:
1621 case XML_ATTRIBUTE_DECL:
1622 case XML_ENTITY_DECL:
1623 case XML_NAMESPACE_DECL:
1624 case XML_XINCLUDE_START:
1625 case XML_XINCLUDE_END:
1626 ret = 1;
1627 break;
1628 }
1629 for (;list != NULL;ret++)
1630 list = list->next;
1631 return(ret);
1632}
1633
1634/**
1635 * xmlLsOneNode:

Callers 1

xmlLsOneNodeFunction · 0.85

Calls 1

xmlStrlenFunction · 0.85

Tested by

no test coverage detected