[ PHPXref.com ] [ Generated: Sun Jul 20 18:31:52 2008 ] [ Mailing List 1.03 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/lib/ -> xml.php (source)

   1  <?php
   2  class CXMLParser {
   3      var $parser;
   4      var $namespace;
   5      var $attr_namespace = FALSE;
   6      var $tag;
   7      var $attr;
   8  	function CXMLParser() {
   9      }
  10  	function InitParser() {        
  11          $this->parser = xml_parser_create();
  12          xml_set_object($this->parser,&$this);
  13          xml_set_element_handler($this->parser,"HNDTagOpen","HNDTagClose");
  14          xml_set_character_data_handler($this->parser,"HNDCData");
  15      }
  16  	function HNDTagOpen($parser,$tag,$attr) {
  17          if (strpos($tag,":")) {
  18              list($namespace,$tag) = explode(":",$tag);
  19              $this->namespace = $namespace;
  20          }
  21          $attr_namespace = FALSE;
  22          foreach ($attr as $key => $val) {
  23              if (strpos($key,":")) {
  24                  $attr_namespace = TRUE;
  25                  list($namespace,$name) = explode(":",$key);
  26                  $_attr["$namespace"]["$name"] = $val;
  27              } else
  28                  $_attr["$key"] = $val;
  29          }
  30          if ($attr_namespace == TRUE) {
  31              $attr = $_attr;
  32              $this->attr_namespace = TRUE;
  33          } else
  34              $this->attr_namespace = FALSE;
  35          $this->tag = $tag;
  36          $this->attr = $attr;
  37      }
  38  	function HNDTagClose($parser,$tag) {
  39          $this->tag = "";
  40          $this->attr = "";
  41      }
  42  	function HNDCData($parser,$cdata) {
  43          echo "<br>" .    $cdata;
  44      }
  45  	function Parse($data) {
  46          $this->namespace = "";
  47          $this->attr_namespace = FALSE;
  48          $this->tag = "";
  49          $this->attr = array();
  50          $this->InitParser();
  51          xml_parse($this->parser,$data);
  52          xml_parser_free($this->parser);
  53      }
  54  }
  55  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]