Welcome Guest, Not a member yet? Register   Sign In
About RSS feeds

Hello everybody.

A couple weeks ago I stumbled upon this post by Derek Allard about how to implement an RSS feed in CI. The post itself is very self-explanatory, but what I didn't understand is the RSS feed code. Here it is:

echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
<rss version="2.0"

    &lt;title&gt;&lt;?php echo $feed_name; ?&gt;&lt;/title&gt;

    &lt;link&gt;&lt;?php echo $feed_url; ?&gt;&lt;/link&gt;
    <description>&lt;?php echo $page_description; ?&gt;</description>
    <dc:language>&lt;?php echo $page_language; ?&gt;</dc:language>
    <dc:creator>&lt;?php echo $creator_email; ?&gt;</dc:creator>

    <dc:rights>Copyright &lt;?php echo gmdate("Y", time()); ?&gt;</dc:rights>
    <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />

    &lt;?php foreach($posts->result() as $entry): ?&gt;

          &lt;title&gt;&lt;?php echo xml_convert($entry->post_title); ?&gt;&lt;/title&gt;
          &lt;link&gt;&lt;?php echo site_url('blog/post/' . $entry->url_title) ?&gt;&lt;/link&gt;
          <guid>&lt;?php echo site_url('blog/post/' . $entry->url_title) ?&gt;</guid>

      &lt;?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $entry->post_body); ?&gt;
      <pubDate>&lt;?php echo date ('r', $entry->post_date);?&gt;</pubDate>

    &lt;?php endforeach; ?&gt;

Now it's the first time I actually try to build an RSS feed, so I don't know a thing about them. I did some research, and what I found is this code (and a couple other code similar code snippets):

&lt;?xml version="1.0"?&gt;
<rss version="2.0">
        &lt;title&gt;Liftoff News&lt;/title&gt;
        <description>Liftoff to Space Exploration.</description>
        <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
        <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
        <generator>Weblog Editor 2.0</generator>
        <managingEditor>[email protected]</managingEditor>
        <webMaster>[email protected]</webMaster>
            &lt;title&gt;Star City&lt;/title&gt;
            <description>How do Americans get ready to work with Russians aboard the International Space Station?</description>
            <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>

What I don't understand is what are the xmlns attributes in the rss opening tag and the dc: tags. I know this doesn't really have anything to do with CI itself, but can somebody (try) to explain to me what Derek's code means please?

Use SimplePie and You'll be happy :-)

As far as I know SimplePie is to retrieve RSS feeds and display/style them easily. What I want to do is create my own RSS feed. Additionally, SimplePie is not actively developped anymore.

Anyway, regardless of what I just wrote above, I don't want to rely on an external script for something as simple as RSS.

Can anyone else try to answer my question please?

it is a namespace, to tell browsers where to find the document type definitions ( ~ xml schema) so it can render the page properly. But you can remove them, it'll still work as a charm

for more reading - Wikipedia

how to use simple pie accelerator to codeligniter?? i had problem with that

Theme © iAndrew 2016 - Forum software by © MyBB