note 91480 modified in function.simplexml-element-xpath by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Sep 2009 15:50:25 +0000 |
| Subject: | note 91480 modified in function.simplexml-element-xpath by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160672@lists.php.net to get a copy of this message | ||
The simplest way to count nodes in a XML doc:
<?php
$xml = new SimpleXMLElement($xmlstr);
$xmlNode = $xml->xpath('root/yourNodeName');
$nodeCount = count($xmlNode);
echo $nodeCount;
?>
--was--
The simplest way to count nodes in a XML doc:
<?php
$xml = new SimpleXMLElement($xmlstr);
$xmlNode = $xml->xpath('root/yourNodeName');
$nodeCount = count($xmlNode);
echo $nodeCount;
?>
http://php.net/manual/en/function.simplexml-element-xpath.php