Page 1 of 1

PHP feed reader for both RSS and ATOM

Posted: Wed Nov 16, 2011 5:27 pm
by Rksk
I tried to read RSS feeds using php. Then started with following code.

Code: Select all

<?php
$parser=xml_parser_create();

function char($parser,$data)
  {
  echo $data;
  }

xml_set_character_data_handler($parser,"char");
$fp=@fopen("https://robot.lk/rss.php","r");

while ($data=fread($fp,4096))
  {
  xml_parse($parser,$data,feof($fp)) or
  die (sprintf("XML Error: %s at line %d",
  xml_error_string(xml_get_error_code($parser)),
  xml_get_current_line_number($parser)));
  }

xml_parser_free($parser);
?> 
But it gave folllowing error with many FEEDs.
XML Error: Invalid character at line xx
Please, can anyone explain that, why it happens at always?

Thankz.

Re: PHP feed reader for both RSS and ATOM

Posted: Wed Nov 16, 2011 7:31 pm
by Saman
Check a RSS feed of a different provider.