Subscribe: How do you generate an RSS feed? - Stack Overflow
http://stackoverflow.com/feeds/question/257339
Added By: Feedage Forager Feedage Grade A rated
Language: English
Tags:
answer  config system  document  feed  generate feed  generate  import namespace  import  namespace system  namespace  new  system  xml 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: How do you generate an RSS feed? - Stack Overflow

How do you generate an RSS feed? - Stack Overflow



most recent 30 from stackoverflow.com



Updated: 2018-04-22T11:53:38Z

 



How do you generate an RSS feed?

2009-10-10T02:45:11Z

I've never done it myself, and I've never subscribed to a feed, but it seems that I'm going to have to create one, so I'm wondering. The only way that seems apparent to me is that when the system is updated with a new item (blog post, news item, whatever), a new element should be written to the rss file. Or alternatively have a script that checks for updates to the system a few times a day and writes to the rss file is there is. There's probably a better way of doing it though.

And also, should old elements be removed as new ones are added?

Edit: I should have mentioned, I'm working in PHP, specifically using CodeIgniter, with a mySQL database.




Answer by Drew Olson for How do you generate an RSS feed?

2008-11-02T20:56:45Z

I'd say the answer is having an RSS feed be nothing more than another view of your data. This means that your rss feed is simply an xml representation of the data in your database. Readers will then be able to hit that specific url and get back the current information in your application.




Answer by Eoin Campbell for How do you generate an RSS feed?

2008-11-02T20:57:47Z

An RSS Feed is just an XML Document that conforms to a specific schema.

Have a look here

What language are you working in? You can easily script the xml output based on some content in your application. You don't need to explicitly save the file to the file system. It can just be created on the fly




Answer by Nick for How do you generate an RSS feed?

2008-11-02T21:00:41Z

Here's a simple ASP.NET 2 based RSS feed I use as a live bookmark for my localhost dev sites. Might help you get started:

<%@ Page Language="C#" EnableViewState="false" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.DirectoryServices" %>





Answer by Greg B for How do you generate an RSS feed?

2008-11-02T21:12:44Z

An RSS feed is just an XML document formatted in a certain way and linked to from a web page.

Take a look at this page (http://cyber.law.harvard.edu/rss/rss.html) which details the RSS specification, gives example RSS files for you to look at and shows you how to link to them from your site.

How you create the document is up to you. You could write it manually in a text editor, use a language specific XML object, or hit an ASPX/PHP/other page and send the correct content type headers along with the RSS document.

It's not all that hard when you get down to it. good luck!




Answer by da5id for How do you generate an RSS feed?

2008-11-02T21:35:42Z

I've got good results from Magpie RSS. Set up the included cacheing and all you need to do is write the query to retrieve your data and send the result to Magpie RSS, which then handles the update frequency.

I wouldn't be writing an RSS file, unless your server is under particularly heavy load - one query (or a series of queries that adds to an array) for updated stuff is all you need. Write the query/ies to be sorted by date and then limited by X and you won't need to worry about 'removing old stuff' either.




Answer by Scott Reynen for How do you generate an RSS feed?

2008-11-02T22:00:55Z

There are two ways to approach this. The first is to create the RSS document dynamically on request. The second is to write to a static file when a relevant change happens. The latter is faster, but requires a call to update the feed in (likely) many places vs. just one.

With both methods, while you could edit the document with only the changes, it's much simpler to just rewrite the whole document every time with the most recent (10-50) items.




Answer by Zoredache for How do you generate an RSS feed?

2008-11-03T05:28:21Z

For PHP I use feedcreator http://feedcreator.org/

useCached();
$rss->title = "Item List";
$rss->cssStyleSheet='';
$rss->description = 'this feed';
$rss->link = CONFIG_SYSTEM_URL;
$rss->syndicationURL = CONFIG_SYSTEM_URL.'feed.php';


$articles=new itemList();  // list of stuff
foreach ($articles as $i) {   
    $item = new FeedItem();
    $item->title = sprintf('%s',$i->title);
    $item->link = CONFIG_SYSTEM_URL.'item.php?id='.$i->dbId;
    $item->description = $i->Subject;   
    $item->date = $i->ModifyDate;   
    $item->source = CONFIG_SYSTEM_URL;   
    $item->author = $i->User;
    $rss->addItem($item);
}

print $rss->createFeed($feedformat);



Answer by Ciaran McNulty for How do you generate an RSS feed?

2008-11-04T09:59:02Z

If you want to generate a feed of elements that already exist in HTML, one option is to modify your HTML markup to use hAtom (http://microformats.org/wiki/hAtom) and then point feed readers through an hAtom->Atom or hAtom->RSS proxy.