RSS and You (Make your own RSS Feed)

 Over the years, blogging has become a huge hit sesation. Everyone and the dog seems to have one (I have seen blogs for dogs before...) Chances are if you are reading this, you have one or are looking to get one for yourself. But with everyone having a blog, it's a pain to go around to every blog that you follow and watch them everyday. This is where RSS comes in. RSS stands for Really Simple Syndication, and it's just that. It's incredibly simply to create and maintain, and also will help get your information out there.

When starting a blog, one of the main things you want to do is get your name out there so you can get readers, so places like google and many others will save a list of RSS feeds submitted to them, and will check these feeds and post your news articles based on what information you have provided.

There are many different sites that will generate RSS feeds for you, by either plugging into your site or by submitting your articles to them. The only problem with these is that you may not have complete control over every aspect of your RSS feed. I am going to show you how to make your own very simple XML file that meets all the RSS standards.

RSS is just an XML file with a certain set of tags in a certain order. It's that simply. So let's begin. Just like in HTML (or any kind of markup code, even BBCode), you have to put things between tags.. you have an open tag <tagname> and a closing tag </tagname>

We begin any XML file by telling the browser what version of XML we are using.

<?xml version="1.0" ?>

Now, everything will go instead our RSS tags. This tag will also tell the RSS aggrigator (the thing that reads your RSS file) what version standards you are following. We are going to be following the current 2.0 standard.

<rss version="2.0"> ... </rss>

The information about your site (not the individual article) is called a channel. Your channel has the following information:

  • Description: A small description of your site and the kind of content you have
  • Link: The full URL to your website, not to an individual article
  • Title: The title of your website

Here is what we have so far:

rss.xml

<?xml version="1.0"?>
<rss version="2.0">
   <channel>
     <title>Name of your site</title>
     <description>My site is about some stuff, then there is more stuff</description>
     <link>http://www.mywebsite.com/</link>
   <channel>
</rss>

 We are only missing 1 more aspect of our XML document to make it a complete and valid RSS feed. This is the main part, the item tags. You will have multiple item tags that will display all of your articles (or atleast the ones you want to publish)

The parts of your item tag that we will include area:

  • Title: The name of your article
  • Link: The URL of your article
  • Description: the description of your article
  • pubDate: the date and time your article was written, must follow the RFC standards

The RFC standard for the pubDate looks something like this: "Tue, 03 Jun 2003 09:39:21 GMT". If you are generating this date from a timestamp in PHP (and I would assume similar languages), you can use:

date('r', $pubDateTimeStamp);

Now let's write our XML document for 2 articles, and see how it looks.

rss.xml

<?xml version="1.0"?>
<rss version="2.0">
   <channel>
     <title>Name of your site</title>
     <description>My site is about some stuff, then there is more stuff</description>
     <link>http://www.mywebsite.com/</link>
   <channel>

   <item>
        <title>Article #1</title>
        <link>http://www.mywebsite.com/article1</link>
        <description>Here is a small article about something</description>
        <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
    </item>

   <item>
        <title>Article #2</title>
        <link>http://www.mywebsite.com/article2</link>
        <description>Here is a small article about something</description>
        <pubDate>Wed, 04 Jun 2003 09:39:21 GMT</pubDate>
    </item>

</rss>

That's it! We have finished our simple XML document! There are a ton of more tags you can and probably should add in to various parts of your XML document but they are not required. Here is a full listing of RSS tags.

For those of you that would like a script that will automate this process, I have written a library you can use to generate an RSS feed for you and customize all of it. You are free to edit it aswell, simply go to the Download Section of My Blog, The Sink Files.

Now, let the world know all about what you have to say!

More by this Author

  • Regex for BBCode in PHP
    5

     Regular Expressions (Regex) are a way to parse information and match it with a larger string. For example, If you wanted to validate an email address, you could write a regular expression that would try and match...


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working