RSS文档

来源:互联网 发布:win7怎么显示网络图标 编辑:程序博客网 时间:2024/05/22 22:53

RSS文档


1、RSS 0.91文档
RSS 0.91是最常用的RSS格式,很早,简单。
RSS 0.91没有为元素声明命名空间。
1)rss元素是文档元素,它有一个必须的属性version,值为0.91。
2)该文档要求只有一个channel子元素和一个或多个item子元素。channel的元素包括:
3)title 描述性标题
4)link 用于channel的url
5)description channel的描述
6)频道的可选子元素:
7)copyright 频道的版权通知
8)docs 关于频道使用的RSS格式的文档
9)lastBuildDate 上次更改频道内容的日期
10)managingEditor 为频道管理编辑器的电子邮件地址
11)pubDate 频道的发布日期
12)rating (Platform Internet Content Selection)平台(PICS)的等级
13)skipDays 跳过阅读频道的天数
14)skipHours 跳过阅读频道的小时
15)textInput 用于频道的文本输入框,如搜索框
16)webMaster 频道网络管理员的电子邮件地址
----------------------
例子:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="0.91">
 <channel>
  <title>Wy'seast Communications</title>
  <link>http://www.wyeast.net</link>
  <description>Wy'east Communications is an XML consultancy.</description>
  <language>en-us</language>
  <image>
   <url>http://www.wyeast.net/images/mthood.jpg</url>
   <title>Wy'east</title>
   <link>http://www.wyeast.net</link>
  </image>
  <item>
   <title>Legend of Wy'east</title>
   <link>http://www.wyeast.net/wyeast.html</link>
   <description>The Native American story behind the name Wy'east.</description>
  </item>
 </channel>
</rss>
----------------------
2、RSS 1.0文档
RSS 1.0是RSS 0.91的一个分支,将来自W3C的资源描述框架(Resource Description Framework, RDF)的元素进行合并。RSS 1.0文档目前是用于RSS文档的一种流行格式,仅次于RSS 0.91。
1)RDF命名空间的rdf:RDF元素是文档元素,该元素只能有一个channel子元素,可有一个或多个item子元素。来自RDF命名空间的channel上的rdf:about数学将提要视为URI。
2)title 描述性标题
3)link 用于channel的url
4)description channel的描述
5)items 包含RDF元素Seq和li。
6)channel的另外两个可能的子元素是image和textinput,通过rdf:resource属性与其它image和textinput元素相链接,可选择性地在文档中用作rdf:RDF的子元素。
----------------------
例子:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns="http://pure.org/rss/1.0" xmlns:rdf="http://www.w3.org/1999/02/22
-rdf-syntax-ns#">
 <channel rdf:about="http://www.wyeast.net/wyeast.rss">
  <title>Wy'east Communications</title>
  <link>http://www.wyeast.net</link>
  <description>Wy'east Communications is an xml consultancy.</description>
  <items>
   <rdf:Seq>
    <rdf:li rdf:resource="http://www.wyeast.net/wyeast.html"/>
   </rdf:Seq>
  </items>
 </channel>
 <item rdf:about="http://www.wyeast.net/wyeast.html">
  <title>Legend of Wy'east</title>
  <link>http://www.wyeast.net/wyeast.html</link>
  <description>The Native American story behind the name Wy'east.</description>
 </item>
</rdf:RDF>
----------------------
3、创建RSS 2.0文档
RSS 2.0是RSS 0.91的更新版,故没有遵循RSS 1.0所采用的RDF方法。它是RSS第三种流行的RSS格式。
1)与RSS 0.91类似,RSS 2.0没有为其自己的元素声明一个命名空间。rss是文件元素,它必须有一个值为2.0的version属性。
2)channel元素是必须的,其子元素title、link、description也是必须的。language在0.91下是必须的元素,但在2.0下则是可选的;image也是如此。
3)channel的可选子元素为:image、copyright、managingEditor、webMaster、pubDate、lastBuildDate、rating、docs、textInput、skipDays、skipHours、category、generator(生成器程序的名字)、cloud(指定用于发布和订阅提要的协议)、ttl(存活的分钟数)。
4)item的可选子元素有:title、link、description、author、category、comments、enclosure、guid(全局唯一标识符)、pubDate(RFC822格式书写的发布日期)、source(RSS频道和项的来源)。
----------------------
例子:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
 <channel>
  <title>Wy'east Communications</title>
  <link>http://www.wyeast.net</link>
  <description>Wy'east Communications is an XML consultancy.</description>
  <item>
   <title>Legend of Wy'east</title>
   <link>http://www.wyeast.net/wyeast.html</link>
   <description>The Native American story behind the name Wy'east.</description>
  </item>
 </channel>
</rss>
----------------------