RSS 实例
这些例子使用我们的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 项目添加发布资料
实例
<?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>
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例解析