Extra semicolon (RSS Feed) - El Forum - 04-15-2010
[eluser]xmonader[/eluser]
Hi, I'm trying to build some RSS Feed http://www.derekallard.com/blog/post/building-an-rss-feed-in-code-igniter/
rss.php
Code: <?php echo '<?xml version="1.0" encoding="UTF-8"?>'?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo $feed_name; ?></title>
<link><?php echo $feed_url; ?></link>
<description><?php echo $page_description; ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; ?></dc:creator>
<dc:rights>Copyright <?php echo gmdate("Y", time()); ?></dc:rights>
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
<?php foreach($posts->result() as $entry): ?>
<item>
<title><?php echo xml_convert($entry->topic_title); ?></title>
<link><?php echo site_url('main/topic_view/'. $entry->topic_id) ?></link>
<guid><?php echo site_url('main/topic_view/'. $entry->topic_id) ?></guid>
<description><![CDATA[
<?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $entry->post_text); ?>
]]></description>
<pubDate><?php echo date ('r', mysql_to_unix($entry->topic_start_time));?></pubDate>
</item>
<?php endforeach; ?>
</channel>
</rss>
after calling the controller i get
Code: <?xml version="1.0" encoding="UTF-8"; ?>
...
REST OF RSS
I don't know what appends that semicolon?
Extra semicolon (RSS Feed) - El Forum - 04-15-2010
[eluser]pickupman[/eluser]
I don't know if it's a typo on the board but shouldn't the first line be changed from:
Code: <?php echo '<?xml version="1.0" encoding="UTF-8"?>'?>
// Change to
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
Extra semicolon (RSS Feed) - El Forum - 04-15-2010
[eluser]xmonader[/eluser]
pickupman: Yes the first line is
Code: <?php echo '<?xml version="1.0" encoding="UTF-8"?>';?>
Even if i replace it with Code: <?xml version="1.0" encoding="UTF-8"?>
It gets transformed to Code: <?xml version="1.0" encoding="UTF-8"; ?>
Extra semicolon (RSS Feed) - El Forum - 04-15-2010
[eluser]xmonader[/eluser]
Got it fixed --short tags problem
here's the simple way
Code: <?= '<' . '?xml version="1.0" encoding="utf-8"?' . '>' ?>
Thanks
Extra semicolon (RSS Feed) - El Forum - 05-04-2011
[eluser]xmonader[/eluser]
After checking a few applications updated to CI 2 I found that all feeds are broken! and none of the snippets above are working.
The only working thing is
Code: //FIX ME.
echo header("Content-Type: application/rss+xml".'?xml version="1.0" encoding="utf-8"?' . '>');
$this->load->view('rss', $data);
Extra semicolon (RSS Feed) - El Forum - 05-04-2011
[eluser]pickupman[/eluser]
You don't echo the header(). I put this as the first line of the controller's method:
Code: header("Content-Type: application/rss+xml");
Here his the first line of my view:
Code: <?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
Extra semicolon (RSS Feed) - El Forum - 05-04-2011
[eluser]xmonader[/eluser]
Thanks, but still doesn't work
Code: function index() {
//FIX ME.
header("Content-Type: application/rss+xml");
$data['encoding'] = 'utf-8';
$data['feed_name'] = $this->Cikimeta_model->getMetaValue("wiki", "wiki_title");
$data['feed_url'] = base_url();
$data['page_description'] = 'SOME DESCRIPTION';
$data['page_language'] = 'en-ca';
$data['creator_email'] = 'Ahmed Youssef is at xmonader[at]gmail[dot]com';
$data['posts'] = $this->Pages_model->getLatestPages(10);
$this->load->view('rss', $data);
}
the RSS view
Code: <?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo $feed_name; ?></title>
<link><?php echo $feed_url; ?></link>
<description><?php echo $page_description; ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; ?></dc:creator>
<dc:rights>Copyright <?php echo gmdate("Y", time()); ?></dc:rights>
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
<?php foreach($posts->result() as $entry): ?>
<item>
<title><?php echo xml_convert($entry->page_title); ?></title>
<link><?php echo site_url('pages/'. $entry->page_id) ?></link>
<guid><?php echo site_url('topic/view_topic/'. $entry->page_id) ?></guid>
<description><![CDATA[
<?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', word_limiter($entry->pagecontent, 25)) ?>
]]></description>
<pubDate><?php echo date ('r', mysql_to_unix($entry->createdat));?></pubDate>
</item>
<?php endforeach; ?>
</channel>
</rss>
Hmmm..?
Extra semicolon (RSS Feed) - El Forum - 05-04-2011
[eluser]InsiteFX[/eluser]
You still have a short tag here!
Code: <?= str_replace('/img/post_resources/', base_url()
InsiteFX
Extra semicolon (RSS Feed) - El Forum - 05-05-2011
[eluser]xmonader[/eluser]
still not working :S
Code: <?xml version="1.0" encoding="utf-8"; ?>
adding that semi colon is driving me crazy
Extra semicolon (RSS Feed) - El Forum - 05-05-2011
[eluser]pickupman[/eluser]
Just out of curiosity, do you have rewrite short tags set to true at the near bottom of your application/config.php file?
What happens when you try again:
Code: <?php echo '<?xml version="1.0" encoding="utf-8"?' . '?>' . "\n"; ?>
//or maybe
<?php echo str_replace(';','','<?xml version="1.0" encoding="utf-8"?' . '?>'). "\n"; ?>
|