Possible Duplicate:
SimpleXML: How to find number of children of top-level element?
php count xml elements
I have got this code:
$string = <<<XML
<?xml version='1.0'?>
<document>
<title>Forty What?</title>
<from>Joe</from>
<to>Jane</to>
<body>
I know that's the answer -- but what's the question?
</body>
</document>
XML;
$xml = simplexml_load_string($string);
$data_count = count($data->xml);
print_r($data_count);
I run this code on line Demo
when I perform print_r($data_count); the resualt is “0” instead 10(rows in the string);
what should I do to contain the numbers of the raw in the varible $data_count ?
many thx.
Try this