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

Source for file example2.php

Documentation is available at example2.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.         <title>XML_FOAF_Parser Example</title>
  5.         <meta name="Author" content="" />
  6.         <meta name="Keywords" content="" />
  7.         <meta name="Description" content="" />
  8.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  9.         <style type="text/css">
  10.             table,th,td { border: 1px solid black; }
  11.         </style>
  12.     </head>
  13.     <body>
  14.         <?php
  15.             // Get our FOAF File from $_GET['foaf']
  16.             if (!isset($_REQUEST['foaf'])) {
  17.                 echo "<strong>Please enter a FOAF file below";
  18.             else {
  19.                 $foaf file_get_contents($_REQUEST['foaf']);
  20.     
  21.                 // Require the XML_FOAF_Parser class
  22.                 require_once 'XML/FOAF/Parser.php';
  23.     
  24.                 // Create new Parser object
  25.                 $parser = new XML_FOAF_Parser;
  26.     
  27.                 // Start of output
  28.                 echo '<h1>XML_FOAF_Parser Example</h1>';
  29.                 if (isset($_REQUEST['xml'])) {
  30.                     echo '<pre>' .htmlentities($foaf)'</pre>';
  31.                 }
  32.                 
  33.                 // Parser our FOAF in $foaf
  34.                 require_once 'Benchmark/Timer.php';
  35.                 $timer = new Benchmark_Timer();
  36.                 $timer->start();
  37.                 $parser->parseFromMem($foaf);
  38.                 $timer->setMarker('Time taken to Parse FOAF File');
  39.                 $timer->stop();
  40.                 if (isset($_REQUEST['table'])) {
  41.                     // Show our FOAF as an HTML table
  42.                     echo "<h2>FOAF as HTML Table</h2>";
  43.                     echo $parser->toHTML($parser->toArray());
  44.                 }
  45.                 
  46.                 if (isset($_REQUEST['array'])) {
  47.                     // Show the contents of the FOAF Data array
  48.                     echo "<h2>FOAF as Array</h2>";
  49.                     echo "<pre>";
  50.                     var_dump($parser->toArray());
  51.                     echo "</pre>";
  52.                 }
  53.                 
  54.                 if (isset($_REQUEST['timer'])) {
  55.                     $timer->display();
  56.                 }
  57.             }
  58.         ?>
  59.         <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  60.             <p>
  61.                 <label>FOAF File URI: <input type="text" name="foaf" value="<?php echo(@$_REQUEST['foaf']?>" /></label>
  62.                 <br />
  63.                 Show RDF/XML: <input type="checkbox" name="xml" value="true" />
  64.                 <br />
  65.                 Show as HTML Table: <input type="checkbox" name="table" value="true" checked="checked" />
  66.                 <br />
  67.                 Show as Array: <input type="checkbox" name="array" value="true" />
  68.                 <br />
  69.                 Show Timer: <input type="checkbox" name="timer" value="true" checked="checked" />
  70.                 <br />
  71.                 <input type="submit" value="Parse FOAF!" />
  72.             </p>
  73.         </form>
  74.     </body>
  75. </html>

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