XML_Statistics
[ class tree: XML_Statistics ] [ index: XML_Statistics ] [ all elements ]

Source for file example1.php

Documentation is available at example1.php

  1. <?PHP
  2.     require_once 'XML/Statistics.php';
  3.     
  4.     $stat = new XML_Statistics(array("ignoreWhitespace" => true));
  5.     $result $stat->analyzeFile("example.xml");
  6.     
  7.     if ($stat->isError($result)) {
  8.         die("Error: " $result->getMessage());
  9.     }
  10.     
  11.     // total amount of tags:
  12.     echo    "Total tags: " $stat->countTag()."<br>";
  13.     
  14.     // count amount of 'title' attribute, in all tags
  15.     echo    "Occurences of attribute title: " $stat->countAttribute("title")."<br>";
  16.  
  17.     // count amount of 'title' attribute, only in <section> tags
  18.     echo    "Occurences of attribute title in tag section: " $stat->countAttribute("title""section")."<br>";
  19.  
  20.     // count total number of tags in depth 4
  21.     echo    "Amount of Tags in depth 4: " $stat->countTagsInDepth(4)."<br>";
  22.  
  23.     echo    "Occurences of PHP Blocks: " $stat->countPI("PHP")."<br>";
  24.     
  25.     echo    "Occurences of external entity 'bar': " $stat->countExternalEntity("bar")."<br>";
  26.     
  27.     echo    "Data chunks: " $stat->countDataChunks()."<br>";
  28.  
  29.     echo    "Length of all data chunks: " $stat->getCDataLength()."<br>";
  30. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.