home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / xml_parser_simple1.php < prev    next >
Encoding:
PHP Script  |  2004-10-01  |  1.1 KB  |  50 lines

  1. <?PHP
  2. /**
  3.  * example for XML_Parser_Simple
  4.  *
  5.  * $Id: xml_parser_simple1.php,v 1.2 2004/05/24 21:42:33 schst Exp $
  6.  *
  7.  * @author      Stephan Schmidt <schst@php-tools.net>
  8.  * @package     XML_Parser
  9.  * @subpackage  Examples
  10.  */
  11.  
  12. /**
  13.  * require the parser
  14.  */
  15. require_once 'XML/Parser/Simple.php';
  16.  
  17. class myParser extends XML_Parser_Simple
  18. {
  19.     function myParser()
  20.     {
  21.         $this->XML_Parser_Simple();
  22.     }
  23.  
  24.    /**
  25.     * handle the element
  26.     *
  27.     * The element will be handled, once it's closed
  28.     *
  29.     * @access   private
  30.     * @param    string      name of the element
  31.     * @param    array       attributes of the element
  32.     * @param    string      character data of the element
  33.     */
  34.     function handleElement($name, $attribs, $data)
  35.     {
  36.         printf('handling %s in tag depth %d<br />', $name, $this->getCurrentDepth());
  37.         printf('character data: %s<br />', $data );
  38.         print 'Attributes:<br />';
  39.         print '<pre>';
  40.         print_r( $attribs );
  41.         print '</pre>';
  42.         print '<br />';
  43.     }
  44. }
  45.  
  46. $p = &new myParser();
  47.  
  48. $result = $p->setInputFile('xml_parser_simple1.xml');
  49. $result = $p->parse();
  50. ?>