php - Parsing error -- Creating an RSS feed with CodeIgniter -
hey guys, i'm creating rss feed codeigniter , specific error: xml parsing error: junk after document element location: http://mysite.com/feeds/latest
after googling , not being able find solution issue (despite ton of results) came here advice.
i have
<?xml version="1.0" encoding="utf-8"?> <rss xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0"> <channel> followed websites title, link, description, pubdate, dc:date tags.
followed foreach statement loops results so:
<?php foreach($feedresults $feeditem): ?> <item> <title><?php echo $feeditem->title; ?></title> <link><?php echo site_url('/'.$feeditem->id) ?></link> <guid><?php echo site_url('/'.$feeditem->id) ?></guid> <description>descri[</description> <pubdate><?php echo date ('r', $feeditem->time());?></pubdate> </item> <?php endforeach; ?> my codeigniter controller doesn't besides retrieve $feedresults, sets header : header("content-type: text/xml"); , passes results view.
thanks guys.
if save rss feed off .html extension you'll see it's not rss @ all, it's html error page:
errorexception [ parse error ]: syntax error, unexpected t_string
apppath/views/feeds_latest_view.php [ 1 ]
1 <?xml version="1.0" encoding="utf-8"?> 2 <rss xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0"> 3 <channel> 4 5 <title>amazon.com gold box deals</title> 6 <link>http://www.amazon.com/gp/goldbox</link>
- {php internal call} » my_exceptions::shutdown_handler(arguments)
my guess have php short_tags enabled, means <? shorthand <?php , opens php code block. php choking when sees <?xml tries interpret xml processing directive block of php code.
to fix this, turn off short_tags in php.ini. or workaround writing php code emit directive:
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
Comments
Post a Comment