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

[eluser]AzizLight[/eluser]
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:

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>
    
    &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;
    
        <item>

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

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

        
    &lt;?php endforeach; ?&gt;
    
    </channel></rss>

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):

Code:
&lt;?xml version="1.0"?&gt;
<rss version="2.0">
    <channel>
        &lt;title&gt;Liftoff News&lt;/title&gt;
        &lt;link&gt;http://liftoff.msfc.nasa.gov/&lt;/link&gt;
        <description>Liftoff to Space Exploration.</description>
        <language>en-us</language>
        <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
        <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <generator>Weblog Editor 2.0</generator>
        <managingEditor>[email protected]</managingEditor>
        <webMaster>[email protected]</webMaster>
        <item>
            &lt;title&gt;Star City&lt;/title&gt;
            &lt;link&gt;http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp&lt;/link&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>
            <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
        </item>
    </channel>
</rss>

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?
#2

[eluser]Sbioko[/eluser]
Use SimplePie and You'll be happy :-)
#3

[eluser]AzizLight[/eluser]
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?
#4

[eluser]flaky[/eluser]
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
#5

[eluser]angeal99[/eluser]
how to use simple pie accelerator to codeligniter?? i had problem with that




Theme © iAndrew 2016 - Forum software by © MyBB