tags:

views:

44

answers:

2

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 !!

A: 

See if turning error reporting on provides any information. error_reporting(E_ALL);

jackbot
A: 

Why are you trying to get The xml with fopen? Instead try to get The xml with simplexml_load_file();

if (!$xml = simplexml_load_file("http://domain.com/rss.xml")) 
{
            echo('Unable to load or parse search results feed');
        }
        if (!count($entries = $xml->entry)) {
            echo('No entry found');
        }
        for($i=0;$i<count($entries);$i++) 
        {
            echo $entries->autor;
        }
streetparade