這些例子使用我們的RSS閱讀器來演示RSS。

RSS <channel> 元素

設(shè)置 channel 元素的必選項(xiàng) (<title>, <link>, and <description>)

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

為 RSS 指定 category

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <category>IT/Internet/Web development</category>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <category>News</category>
    <category>Tutorial</category>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

指定用于生成RSS的 程序

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <generator>Notepad</generator>
    <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給RSS指定圖像

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <image>
    <url>http://www.w3cschool.cc/images/logo.png</url>
    <title>W3Cschool.cc</title>
    <link>http://www.w3cschool.cc</link>
  </image>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

為 RSS 指定語言

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <language>en-us</language>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

為 RSS 添加文本輸入框

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <textinput>
    <description>Search Google</description>
    <title>Search</title>
    <link>http://www.google.no/search?</link>
    <name>q</name>
  </textinput>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

為 RSS 指定不需要更新的天

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <skipDays>
    <day>Saturday</day>
    <day>Sunday</day>
  </skipDays>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

實(shí)例解析

RSS <item> 元素

設(shè)置必選項(xiàng) (<title>, <link>, and <description>)

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.w3cschool.cc/xml</link>
    <description>New XML tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給 RSS 項(xiàng)目添加注釋鏈接

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <comments>http://www.w3cschool.cc/rss/comments.php</comments>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給 RSS 項(xiàng)目添加媒體文件

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <enclosure url="http://www.w3cschool.cc/media/3d.wmv"
    length="78645" type="video/wmv" />
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給項(xiàng)目添加唯一標(biāo)識符

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <guid>http://www.w3cschool.cc/rss/item0768</guid>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給 RSS 項(xiàng)目添加發(fā)布資料

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <pubDate>Thu, 27 Apr 2006</pubDate>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

給 RSS 項(xiàng)目添加第三方

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy? -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <source url="http://www.w3cschool.cc">W3Cschool.cc</source>
  </item>
</channel>
</rss>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

實(shí)例解析