To find the number of nodes in a DomNodeList you need to access the length property... sample code to do this:

<?php

$xml = <<<XML
<music>
  <artist id="1">
    <name>The Rolling Stones</name>
    <albums>
      <title>Exile On Main Street</title>
    </albums>
  </artist>
  <artist id="2">
    <name>Aimee Mann</name>
    <albums>
      <title>I'm With Stupid</title>
      <title>Bachelor No. 2</title>
    </albums>
  </artist>
</music>
XML;

$dom = new DomDocument();
$dom->loadXML($xml);
$xpath = new DomXpath($dom);
$nodelist = $xpath->query('/music/artist');
print $nodelist->length;

?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to