XPath avg(), min(), max() functions not found

From: Date: Thu, 08 Jun 2006 12:03:35 +0000
Subject: XPath avg(), min(), max() functions not found
Groups: php.general 
Request: Send a blank email to php-general+get-237597@lists.php.net to get a copy of this message
Hi all. I'm trying to use XPath avg(), min() and max() functions without success. Others functions like count() or sum() works correctly. Here is the code I'm using (PHP 5.1): <?php $xml_str = ' <stats>   <cards>     <card name="My card">       <type name="visits">25</type>       <type name="clicks">7</type>     </card>     <card name="My other card">       <type name="visits">50</type>       <type name="clicks">3</type>     </card>   </cards> </stats> '; $xml_doc = new DOMDocument(); $xml_doc->loadXML($xml_str); $xpath = new DOMXPath($xml_doc); $cards_avg = $xpath->evaluate("avg(//card/type[@name='visits'])"); var_dump($cards_avg); $cards_sum = $xpath->evaluate("sum(//card/type[@name='visits'])"); var_dump($cards_sum); ?> I receive the following output: asterix@apenguin:/tmp$ php test.php PHP Warning:  DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not found in /tmp/test.php on line 23 Warning: DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not found in /tmp/test.php on line 23 PHP Warning:  DOMXPath::evaluate(): Unregistered function in /tmp/test.php on line 23 Warning: DOMXPath::evaluate(): Unregistered function in /tmp/test.php on line 23 object(DOMNodeList)#5 (0) { } float(75) asterix@apenguin:/tmp$ Someone can help me? Thanks in advance Alex

« previous php.general (#237597) next »