Cicode Programming Reference > Cicode Function Categories > XML Functions > XMLGetChildCount

XMLGetChildCount

Retrieves the total number of child nodes for the specified parent node in an XML document in memory.

Syntax

INT XMLGetChildCount(INT hDoc, INT hNode)

hDoc

Handle of the XML document the parent node belongs to. Returned by XMLCreate or XMLOpen.

hNode

Handle of the parent node. Returned by XMLGetRoot, XMLGetChild, XMLGetParent or XMLNodeFind.

Return Value

Number of child nodes, or -1 on error

Related Functions

XMLClose, XMLCreate, XMLGetAttribute, XMLGetAttributeCount, XMLGetAttributeName, XMLGetAttributeValue, XMLGetChild, XMLGetParent, XMLGetRoot, XMLNodeAddChild, XMLNodeFind, XMLNodeGetName, XMLNodeGetValue, XMLNodeRemove, XMLNodeSetValue, XMLOpen, XMLSave, XMLSetAttribute

Example

Following example creates an XML document from local file "H:\Data\books.xml", then selects the first node that matches XPath expression "/bookstore/book/", then gets the number of children of the node.

 

INT hDoc, hNode;
INT nCount;
hDoc=XMLOpen("H:\Data\books.xml");
IF hDoc <> -1 THEN
	hNode = XMLNodeFind(hDoc,"/bookstore/book/");		
	IF hDoc <> -1 THEN
		nCount=XMLGetChildCount(hDoc,hNode);
	End
End		

See Also

XML Functions

Published June 2018