- printf: documentation ( source)
<?php
$xml = <<<EOF
<people>
<person name="Person 1">
<child/>
<child/>
<child/>
</person>
<person name="Person 2">
<child/>
<child/>
<child/>
<child/>
<child/>
</person>
</people>
EOF;
$elem = new SimpleXMLElement($xml);
foreach ($elem as $person) {
//printf("%s has got %d children.\n", $person['name'], $person->count());
printf("%s has got %d children.\n", $person['name'], count($person->children()));
}
?>