i'm trying to count the number of children of a parent in an xml with SimpleXML and i know the name of child to count.How can i do this? Thanks in advance
$xml
is the simple XML variable name
parent is the name of the parent node
children is the name of the children node
echo count($xml->parent->children);
From PHP 5.3+ you can use SimpleXMLElement::count
Or
$sXML= new SimpleXMLElement($xml);
$child = $sXML->children();
echo count($child);