RSS feeds from scratchPosted by Matt Thommes on November 11, 2005 | Post type: Gain RSS is a form of content syndication, excellent for tracking a large number of sites or for simple notifications. With the surging popularity of "blogging" tools, such as WordPress and Movable Type, many users underestimate (and take for granted) the inclusion of RSS capabilities. This article will show you how to create your own RSS feed, from scratch - to track any type of data or information. There are many different types of syndication formats available, but this article will only focus on RSS 2.0. A quick overviewRSS is simply an application of XML. Therefore, it's just an XML text file, with specific elements used. So, creating an RSS file is as simple as creating an HTML file (if you have experience with that). Using your favorite text editor, create a file, and save it with an extension of You'll want to put this file on your web server - somewhere intuitive, such as a directory named, "RSS", or "feeds," but of course, it will work anywhere you put it. Once you've uploaded the file, you can start directing your visitors to that file - or, in the case of private feeds - you'll want to keep that information to yourself. Step 1: Find the sourceThe first thing you need to do is figure out the source of your content. This could be anything from text you write out manually, or information coming from a database. You'll need to continuously populate your RSS file with the latest information. This can be cumbersome at best - so it's helpful if your information is coming from a database, so the RSS file is updated automatically. Step 2: Create the fileThe actual structure of an RSS file is rather simple. Different syndication formats (0.91, 0.92, 1.0, 2.0, Atom, etc.) call for different elements - but sticking with the RSS 2.0 specification things should be a breeze. In your text document, start out with the XML declaration. This line is very important. Make sure it's at the very top of the document, with no blank lines before it - and make sure it's flush up against the left side of the page (no spaces before it):
Next, we declare our application of RSS:
Inside the Here's what we have, so far: <?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> </rss> Next comes the <?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> </channel> </rss> The We start off by providing information about our feed, using self-descriptive tags:
<title> A short, descriptive title for this feed </title>
<link> http://www.mysite.com/ </link>
<description> An interesting tag-line or description of this feed </description>
<language> en-gb </language>
<copyright> Copyright 2005, My Company, Inc. </copyright>
<webMaster> myemail@mysite.com </webMaster>
<image>
<title> A brief title for your image </title>
<url> http://mysite.com/images/rss.jpg </url>
<link> http://www.mysite.com/ </link>
<width> 88 </width>
<height> 31 </height>
<description> A brief description of your image </description>
</image>
You can change all the bold information between the tags, to reflect your own data. A few things to note about the tags:
Next, each "item" should be listed in chronological order - from most recent to least recent - with the most recent on top, and the least recent on the bottom. An "item" is a piece of information that you wish to syndicate. This could be anything from web site news updates, to your own personal checking account information. Using a "blog," as an example - each blog post would be a new item. Each item is wrapped in an
<item>
<title> Distinct title for this item </title>
<link> http://www.mysite.com/item-permalink/ </link>
<pubDate> Thu, 27 Oct 2005 13:55:46 CST </pubDate>
<category> Category of this item </category>
<description>
<![CDATA[
<p>Actual output goes here.</p>
]]>
</description>
</item>
As you can see, each A few things to note about the tags: Again, you can include as many
<item>
...
</item>
<item>
...
</item>
<item>
...
</item>
Here is the full
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title> A short, descriptive title for this feed </title>
<link> http://www.mysite.com/ </link>
<description> An interesting tag-line or description of this feed </description>
<language> en-gb </language>
<copyright> Copyright 2005, My Company, Inc. </copyright>
<webMaster> myemail@mysite.com </webMaster>
<image>
<title> A brief title for your image </title>
<url> http://mysite.com/images/rss.jpg </url>
<link> http://www.mysite.com/ </link>
<width> 88 </width>
<height> 31 </height>
<description> A brief description of your image </description>
</image>
<item>
<title> Distinct title for this item </title>
<link> http://www.mysite.com/item-permalink/ </link>
<pubDate> Thu, 27 Oct 2005 13:55:46 CST </pubDate>
<category> Category of this item </category>
<description>
<![CDATA[
<p>Actual output goes here.</p>
]]>
</description>
</item>
<item>
<title> Distinct title for this item </title>
<link> http://www.mysite.com/item-permalink/ </link>
<pubDate> Thu, 27 Oct 2005 13:55:46 CST </pubDate>
<category> Category of this item </category>
<description>
<![CDATA[
<p>Actual output goes here.</p>
]]>
</description>
</item>
</channel>
</rss>
Step 3: Subscribe to your feed!Once you have completed editing your Then, point your web browser to that file. This should be something like:
Once there, copy and paste that URL, and plug it into your RSS reader, and start enjoying the convenience of RSS notifications! Further readingFor further reading, check out the official RSS 2.0 Specification. About the author(s)Matt Thommes is an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us. Comments
|
Quick Link to this postTTIP.me/1965 |
Quick Link to this comment: http://TTIP.me/c4091