daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class MyParser extends CApplicationComponent{
  3.  
  4.     private $file = "/home/echo66/exemplo.xml";
  5.  
  6.     private $xml_parser;
  7.  
  8.     private $fp;
  9.  
  10.     private $data;
  11.  
  12.     protected function contents($parser, $data){
  13.         echo $data;
  14.     }
  15.  
  16.     protected function startTag($parser, $data){
  17.         echo "<b>";
  18.     }
  19.  
  20.     protected function endTag($parser, $data){
  21.         echo "</b><br />";
  22.     }
  23.    
  24.     function init(){
  25.  
  26.         $this->xml_parser = xml_parser_create();  
  27.  
  28.         xml_set_element_handler($this->xml_parser, "startTag", "endTag");
  29.  
  30.         xml_set_character_data_handler($this->xml_parser, "contents");
  31.  
  32.         $this->fp = fopen($this->file, "r");
  33.  
  34.         $this->data = fread($this->fp, 80000);
  35.  
  36.         if(!(xml_parse($this->xml_parser, $this->data, feof($this->fp)))){
  37.             die("Error on line " . xml_get_current_line_number($this->xml_parser));
  38.         }
  39.  
  40.         xml_parser_free($this->xml_parser);
  41.  
  42.         fclose($this->fp);
  43.     }
  44.  
  45.     function run(){
  46.        
  47.     }
  48.  
  49.    
  50.  
  51. }
  52. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top