XML; $elem = new SimpleXMLElement($xml); foreach ($elem as $car) { printf("%s has %d children.
", $car['name'], $car->count()); }