這些例子使用我們的RSS閱讀器來演示RSS。
RSS <channel> 元素
設置 channel 元素的必選項 (<title>, <link>, and <description>)
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
為 RSS 指定 category
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
指定用于生成RSS的 程序
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給RSS指定圖像
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
為 RSS 指定語言
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
為 RSS 添加文本輸入框
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
為 RSS 指定不需要更新的天
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
實例解析
RSS <item> 元素
設置必選項 (<title>, <link>, and <description>)
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給 RSS 項目添加注釋鏈接
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給 RSS 項目添加媒體文件
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給項目添加唯一標識符
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給 RSS 項目添加發(fā)布資料
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
給 RSS 項目添加第三方
實例
<?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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
實例解析