You can accomplish this using PHP. Assuming you have a database with the news in it, you could do something like the following:
feed.php
PHP Code:
<?php
header('Content-type: application/rss+xml');
// Code by andrew247
class essentials{
private $rootURL;
// returns the base URL of the website
function rootURL(){
$this->rootURL = "http://www.yourdomain.com";
return $this->rootURL;
}
}
class feed{
private $rssCode;
function __construct() {
$this->rssCode = Null;
}
public function startRSS(){
$this->rssCode = "<rss version=\"2.0\">\n";
$this->rssCode .= "<channel>\n";
$this->rssCode .= "<title>News</title>\n";
$this->rssCode .= "<link>http://www.yourdomain.co.uk/</link>\n";
$this->rssCode .= "<description>News feed with news entries.</description>\n";
$this->rssCode .= "<lastBuildDate>Fri, 05 Mar 2008 20:41:00 GMT</lastBuildDate>\n";
$this->rssCode .= "<language>en-uk</language>\n";
echo($this->rssCode);
}
public function endRSS(){
$this->rssCode = "</channel>\n";
$this->rssCode .= "</rss>\n";
echo($this->rssCode);
}
}
class database extends essentials{
private $newsID;
private $newsTitle;
private $newsBody;
private $newsDate;
public function dbConnect(){
$db_username = "dbusername";
$db_password = "password";
$database = "database_db";
mysql_connect("db.yourdomain.com",$db_username,$db_password) or die( "Unable to connect to database. :-O");
mysql_select_db($database);
}
public function getFeed($perfeed){
$query = "SELECT * FROM news WHERE accepted='1' order by id desc LIMIT $perfeed";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
$this->newsID = $row['id'];
$this->newsTitle = $row['title'];
$this->newsBody = $row['body'];
$this->newsDate = $row['date'];
$symbols = array("£","$","%","&","^","<br />","<br>");
foreach($symbols as $symbol){
$this->newsBody = str_replace("$symbol", "", "$this->newsBody");
}
include("./feed.entry.php");
}
}
}
$feed = new feed;
$dbQuery = new database;
$feed->startRSS();
$dbQuery->dbConnect();
$dbQuery->getFeed(10);
$feed->endRSS();
?>
feed.entry.php
PHP Code:
<?php
echo("<item>\n");
echo("<title>" . $this->newsTitle . "</title>\n");
echo("<link>" . essentials::rootURL() . "/" . $this->newsID . "/" . $this->newsTitle . "/</link>\n");
echo("<guid>" . essentials::rootURL() . "/" . $this->newsID . "/" . $this->newsTitle . "/</guid>\n");
echo("<pubDate>" . $this->newsDate . "</pubDate>\n");
echo("<description>" . $this->newsBody . "</description>\n");
echo("</item>");
?>
Untested, but should hopefully work.