在網上搜集的比較全的RSS資料
1 軟件環境
使用記事本或者EditPlus或者UltraEdit都可以。
在網上有很多種RSS閱讀器,這裏以“周博通RSS閱讀器”爲例。
IIS或者Apache都可以。
RSS文件實際上就是一個標準的、按着一定格式編寫(具體編寫格式將在下面詳細講解)的XML文件,當然它的擴展名可以是.xml也可以是其他的,如.php、.asp、.aspx、.rss,不管這個文件用何種擴展名命名,其文件內的代碼都是標準的xml代碼,否則RSS閱讀器將無法解釋它。
<?xml version="1.0" encoding="gb2312" ?>
<rss version="2.0">
<channel>
<title>Joe Zhong's First RSS.xml file</title>
<link>http://localhost/</link>
<description>我寫的第一個RSS文件暗暗啊</description>
<language>zh-cn</language>
<generator>Joe Zhong</generator>
<pubDate>2005-8-31</pubDate>
<lastBuildDate>2005-8-31</lastBuildDate>
<item>
<title>泡泡堂、QQ堂遊戲通信架構分析</title>
<link>http://www.163.com/aaa.htm</link>
<category>IT技術</category>
<author>Zhongzhi</author>
<pubDate>Wed, 31 Aug 2005 00:26:00 GMT</pubDate>
<description>能幫助企業降低網絡資產管理管理成本。它將對網絡中每臺工作站的軟、硬件信息進行蒐集整理,以便企業管理者使用。</description>
<comments>介紹這兩款遊戲的通信機制,不足之處還望大家指點!</comments>
</item>
</channel>
</rss>
<?xml version="1.0" encoding="utf-8 " ?>
作用:聲明xml語言的版本和所使用的語言字符集。字符集建議使用utf-8,不過有的服務器在解釋utf-8格式的xml時會報錯,如果報錯的話,就使用簡體中文字符集gb2312。
<rss version="2.0">
作用:聲明rss語言的版本。
每條新聞對應一個item,所有的item都要包含在channel節點下。Xml各節點的詳細說明如下:
<!-- RSS.XML --> <!-- XML版本和字符集 --> <?xml version="1.0" encoding="gb2312" ?> <!-- RSS版本 --> <rss version="2.0"> <!-- 以下爲頻道信息及新聞列表 --> <channel> <!-- 頻道總體信息:開始 --> <!-- 頻道標題 --> <title>Joe Zhong's First RSS.xml file</title> <!-- 頻道鏈接的總地址 --> <link>http://localhost/</link> <!-- 頻道描述文字 --> <description>我寫的第一個RSS文件暗暗啊</description> <!-- 頻道使用的語言(zh-cn表示簡體中文) --> <language>zh-cn</language> <!-- 頻道生成器 --> <generator>Joe Zhong</generator> <!-- 頻道發佈時間 --> <pubDate>2005-8-31</pubDate> <!-- 頻道最後更新時間--> <lastBuildDate>2005-8-31</lastBuildDate> <!-- 頻道總體信息:結束 -->
<!-- 每條RSS新聞信息都包含在item節點中, --> <item> <!-- 新聞標題 --> <title>泡泡堂、QQ堂遊戲通信架構分析</title> <!-- 新聞鏈接地址 --> <link>http://www.163.com/aaa.htm</link> <!-- 新聞目錄 --> <category>IT技術</category> <!-- 新聞作者 --> <author>Zhongzhi</author> <!-- 新聞發佈時間 --> <pubDate>2005 00:26:00</pubDate> <!-- 新聞內容簡要描述 --> <description>能幫助企業降低網絡資產管理管理成本。它將對網絡中每臺工作站的軟、硬件信息進行蒐集整理,以便企業管理者使用。</description> <!-- 新聞註釋[作用不詳] --> <comments>介紹這兩款遊戲的通信機制,不足之處還望大家指點!</comments> </item>
<item> <title>持續集成工具CruiseControl 2.3新版發佈</title> <link>http://news.csdn.net/news/newstopic/25/25811.shtml</link> <category>風花雪月</category> <author>張三</author> <pubDate>2005-8-31 12:30:00</pubDate> <description>持續集成工具CruiseControl今日宣佈發行新版本2.3。</description> <comments>註釋顯示在哪裏?</comments> </item>
</channel> </rss> |
輸出方式和靜態的XML文件大致一樣,不同的是,用服務器腳本輸出RSS文件時,需要指定文件輸出的方式爲XML格式,即設置文件的MIME類型。具體指定方式如下:
在輸出文件的第一行加上如下代碼:
Response.ContentType = "text/xml"
Response.CharSet = "gb2312"
在輸出文件的第一行加上如下代碼:
header("Content-type: text/xml;charset=gb2312");
RSS 2.0規範
版權所有 codesky.net 2003-2005
發表時間:2005-6-3 關鍵字:不詳
RSS是 Really Simple Syndication的縮寫(對rss2.0而言,是這三個詞的縮寫,對rss1.0而言則是RDF Site Summary的縮寫,1.0與2.0走的是兩個體系)
RSS 基於XML,所有的 RSS 必須遵循w3c網站上公佈的XML 1.0 規範。
在一個RSS文檔中,根元素是<rss>,帶有一個必備屬性version,用以指明該文檔遵循的rss規範,如果rss文檔遵循本規範,則version值必須是2.0。
<rss>元素只有一個子元素,包含關於頻道的一些信息。頻道(channel)是整個blog,項(item)指一篇文章或日誌(也有稱這爲post)。
元素(Element) |
描述(Description) |
值域 |
重要性 |
舉例(Example) |
title |
頻道名稱 |
|
必備 |
GoUpstate.com News Headlines |
link |
頻道的URL |
|
必備 |
http://www.goupstate.com/ |
Description |
頻道的描述 |
|
必備 |
The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site. |
|
|
|
|
|
language |
頻道文章所用語言, |
可用netscape或w3c推薦的列表 |
可選 |
en-us |
copyright |
頻道內容的版權說明 |
|
可選 |
Copyright 2002, Spartanburg Herald-Journal |
managingEditor |
責任編輯的email |
|
可選 |
[email protected] (George Matesky) |
webMaster |
負責頻道技術事務的網站管理員email |
|
可選 |
[email protected] (Betty Guernsey) |
pubDate |
頻道內容發佈日期,格式遵循RFC822格式(年份可爲2們或4位) |
|
可選 |
Sat, 07 Sep 2002 00:00:01 GMT |
lastBuildDate |
頻道內容最後的修改日期 |
|
可選 |
Sat, 07 Sep 2002 09:42:31 GMT |
category |
指定頻道所屬的一個或幾個類別 |
|
可選 |
<category>Newspapers</category> |
generator |
生成該頻道的程序名 |
|
可選 |
MightyInHouse Content System v2.3 |
docs |
指向該RSS文件所用格式說明的URL |
|
可選 |
http://blogs.law.harvard.edu/tech/rss |
cloud |
Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds. More info here. |
|
可選 |
<cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/> |
ttl |
有效期,用以指明該頻道可被緩存的最長時間 |
分鐘爲單位 |
可選 |
<ttl>60</ttl> |
image |
指定一個 GIF或JPEG或PNG圖片,用以與頻道一起顯示 |
|
可選 |
|
rating |
這個頻道的分級(主要指成人、限制、兒童等) |
|
可選 |
|
textInput |
指定一個text輸入框供用戶輸入,具體信息及功能未定。 |
|
可選 |
|
skipHours |
提示新聞聚合器,那些小時時段它可以跳過。 |
|
可選 |
|
skipDays |
提示新聞聚合器,那些天它可以跳過。 |
|
可選 |
|
元素(Element) |
描述(Description) |
值域 |
重要性 |
舉例(Example) |
url |
圖片的url |
|
必備 |
|
title |
圖片的標題,用於http的alt屬性 |
|
必備 |
|
link |
網站的url(實際中常以頻道的url代替) |
|
必備 |
|
width |
圖片的寬度(象素爲單位) |
最大144,默認88 |
可選 |
|
height |
圖片的高度(象素爲單位) |
最大400,默認31 |
可選 |
|
description |
用於link的title屬性 |
|
可選 |
|
元素(Element) |
描述(Description) |
值域 |
重要性 |
舉例(Example) |
domain |
Cloud程序所在機器的域名或IP地址 |
|
|
radio.xmlstoragesystem.com |
port |
訪問clound程序所通過的端口 |
|
|
80 |
path |
程序所在路徑(不一定是真實路徑) |
|
|
/RPC2 |
registerProcedure |
註冊的可提供的服務或過程 |
|
|
xmlStorageSystem.rssPleaseNotify |
protocol |
協議 |
xml-rpc, soap , http-post 之一 |
|
xml-rpc |
元素(Element) |
描述(Description) |
值域 |
重要性 |
舉例(Example) |
title |
Submit按鈕的標籤 |
|
必備 |
|
description |
解釋text輸入區 |
|
必備 |
|
name |
Text area對象的名字 |
|
必備 |
|
link |
處理提交的請求的cgi程序 |
|
必備 |
|