Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d1ff49e7d7c3555c40a879f196a056d2 > files > 6

php-pear-XML_Statistics-0.1-10mdv2010.0.noarch.rpm

<?PHP
/**
* This example makes use of
* XML_Statistics in conjunction with
* Math_Stats to calculate average occurences
* and other mathematical statistics
* of all tags in the documents
*/
    require_once 'XML/Statistics.php';
    require_once 'Math/Stats.php';

    $stat = new XML_Statistics();
    $result = $stat->analyzeFile("example.xml");
    
    if ($stat->isError($result)) {
        die("Error: " . $result->getMessage());
    }

    // get number of tags per tagname
	$tags	= $stat->getTagOccurences();

    // use Math_Stats
    $s = new Math_Stats();
	$s->setData($tags);
	$stats = $s->calcBasic();

	echo	"<pre>";
	print_r($stats);
	echo	"</pre>";
?>