Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MyParser extends CApplicationComponent{
- private $file = "/home/echo66/exemplo.xml";
- private $xml_parser;
- private $fp;
- private $data;
- protected function contents($parser, $data){
- echo $data;
- }
- protected function startTag($parser, $data){
- echo "<b>";
- }
- protected function endTag($parser, $data){
- echo "</b><br />";
- }
- function init(){
- $this->xml_parser = xml_parser_create();
- xml_set_element_handler($this->xml_parser, "startTag", "endTag");
- xml_set_character_data_handler($this->xml_parser, "contents");
- $this->fp = fopen($this->file, "r");
- $this->data = fread($this->fp, 80000);
- if(!(xml_parse($this->xml_parser, $this->data, feof($this->fp)))){
- die("Error on line " . xml_get_current_line_number($this->xml_parser));
- }
- xml_parser_free($this->xml_parser);
- fclose($this->fp);
- }
- function run(){
- }
- }
- ?>
Add Comment
Please, Sign In to add comment