听起来很高深.其实就是读取数据,然后输出xml格式的数据.
一种是动态输出rss,另一个是静态输出,原理基本一样,下面的是动态生成rss。
比如我生成就是这样子:
<rss version="2.0" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"> <channel> <title>这里是网站名称</title> <link>网站网址</link> <description>网站描述</description> <language>语言</language> <generator>www.doyouhaobaby.com</generator> <item> <title>test</title> <link>news-139.html</link> <pubDate>Fri, 24 Jun 2011 01:08:04 +0000</pubDate> <author></author> </item> <item> <title>ttttttttttttttttttttt3</title> <link>news-132.html</link> <pubDate>Wed, 22 Jun 2011 01:44:18 +0000</pubDate> <author></author> </item> </channel> </rss>
下面是代码!
include ("config.inc.php"); //从数据库中取数据 $log = $DB->getall( "select * from `article` where SortPath like '0,2,%' order by `DateTime` desc limit 0,48 " ); $now = date ( "D,d M Y H:i:s T" ); $blogurl = $_SERVER ["HTTP_HOST"]; $blogurl = "http://" . $blogurl; header ( 'Content-type: application/xml' ); /* $d_rss .= "\r\n"; */ $d_rss .= "\r\n"; $d_rss .= " "; #输出到客户端 echo $d_rss;\r\n"; $d_rss .= " \r\n超级计算机 \r\n"; $d_rss .= "http://www.sunhaibing.com\r\n"; $d_rss .= "技术分享 \r\n"; $d_rss .= "en-us \r\n"; $d_rss .= "www.doyouhaobaby.com \r\n"; #循环输出rss数据 foreach ( $log as $value ) { $d_rss .= "- \r\n
\r\n"; } $d_rss .= "" . $value ["Title"] . " \r\nnews-" . $value ["Id"] . ".html\r\n" . date ( 'r', $value ['DateTime'] ) . " \r\n" . $value ["Auther"] . " \r\n
近期评论