xml parsing in php issue

Posted by jan on Stack Overflow See other posts from Stack Overflow or by jan
Published on 2010-02-20T17:08:36Z Indexed on 2010/06/15 19:02 UTC
Read the original article Hit count: 137

Filed under:
|
|

I have this code/function method as part of a class in php:

function defaulthome(){


    $fp = null;
    $err  ='';
    $xml_parser = xml_parser_create();    
    $rss_parser = new Rssparser();    
    xml_set_object($xml_parser,&$rss_parser);    
    xml_set_element_handler($xml_parser, "startElement", "endElement");    
    xml_set_character_data_handler($xml_parser, "characterData");    
    $fp = fopen("http://gulfnews.com/cmlink/business-rss-feed-1.446098?localLinksEnabled=false","r");  

      if(!$fp) $err = "Error reading RSS data.";  
      else {  

            $count = 0;

            while ($data = fread($fp, 4096) && $count<10) {  
                xml_parse($xml_parser, $data, feof($fp)) or $err=xml_error_string(xml_get_error_code($xml_parser)); 


                $count++;
            }


    }

    fclose($fp);    
    xml_parser_free($xml_parser);

    $content_sect2 = $this->tnjn->render('forms/landlords_prompt.phtml');
    $context = array('content1_title'=>'Welcome to my website','content1_article'=>"test article", 'feeds'=>$err);
    $output = $this->tnjn->render("default.phtml", $context);
    return $output; 

}

I don't get results and the error i have is empty document! Does anyone know which part of the code is the problem?

Thanks very much !!

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml