通过 RSS,可以将最新的 Web 内容从一个网站分发到世界各地数以千计的其他网站。
RSS 允许快速浏览新闻和更新。
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>91xjr Home Page</title>
<link>https://www.91xjr.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>https://www.91xjr.com/xml/xml_rss.html</link>
<description>New RSS tutorial on 91xjr</description>
</item>
<item>
<title>XML Tutorial</title>
<link>https://www.91xjr.com/xml</link>
<description>New XML tutorial on 91xjr</description>
</item>
</channel>
</rss>
RSS 旨在显示选定的数据。
如果没有 RSS,用户将必须每天检查您的网站是否有新更新。对于许多用户来说这可能太耗时。通过 RSS 源(RSS 通常称为新闻源或 RSS 源),他们可以使用 RSS 聚合器(收集和整理 RSS 源的网站或程序)更快地检查您的网站。
由于 RSS 数据小且加载速度快,因此可以轻松地与手机或 PDA 等服务一起使用。
具有类似信息的网络环可以轻松地在其网站上共享数据,从而使网站变得更好、更有用。
很少更新网站的站长不需要RSS!
RSS 对于经常更新的网站很有用,例如:
以下是使用 RSS 的一些好处:
选择您的新闻
通过 RSS,您可以选择查看您想要的新闻、您感兴趣的且与您的工作相关的新闻。
删除不需要的信息
通过 RSS,您可以(最终)将想要的信息与不需要的信息(垃圾邮件)分开!
增加您的网站流量
使用RSS,您可以创建自己的新闻频道,并将其发布到互联网上!
RSS 1.0 是唯一使用 W3C RDF(资源描述框架)标准开发的版本。
RDF 背后的想法是帮助创建语义网。然而,这对于普通用户来说并不重要,但是通过使用网络标准,个人和应用程序可以更轻松地交换数据。
RSS 0.91 和 RSS 2.0 比 RSS 1.0 更容易理解。我们的教程基于 RSS 2.0。
RSS 2.0的语法规则非常简单,也非常严格。
RSS 没有官方标准。
RSS 用于在网站之间共享内容。
通过 RSS,您可以向称为聚合器的公司注册您的内容。
因此,要参与其中:首先,创建一个 RSS 文档并使用 .xml 扩展名保存它。然后,将文件上传到您的网站。接下来,向 RSS 聚合器注册。聚合器每天都会在注册网站上搜索 RSS 文档,验证链接并显示有关提要的信息,以便客户可以链接到他们感兴趣的文档。
提示:阅读我们的 RSS 发布章节以查看免费的 RSS 聚合服务。
RSS 文档使用自描述且简单的语法。
这是一个简单的 RSS 文档:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>91xjr Home Page</title>
<link>https://www.91xjr.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>https://www.91xjr.com/xml/xml_rss.html</link>
<description>New RSS tutorial on 91xjr</description>
</item>
<item>
<title>XML Tutorial</title>
<link>https://www.91xjr.com/xml</link>
<description>New XML tutorial on 91xjr</description>
</item>
</channel>
</rss>
文档中的第一行 - XML 声明 - 定义文档中使用的 XML 版本和字符编码。在本例中,文档符合 XML 1.0 规范并使用 UTF-8 字符集。
下一行是 RSS 声明,它标识这是一个 RSS 文档(在本例中为 RSS 版本 2.0)。
下一行包含 <channel> 元素。该元素用于描述 RSS 提要。
<channel> 元素具有三个必需的子元素:
每个 <channel> 元素可以有一个或多个 <item> 元素。
每个 <item> 元素定义 RSS 提要中的一篇文章或"story"。
<item> 元素具有三个必需的子元素:
最后,最后两行关闭 <channel> 和 <rss> 元素。
在 RSS 中编写注释的语法与 HTML 类似:
<!-- This is an RSS comment -->
由于 RSS 是 XML,因此请记住:
RSS <channel> 元素描述 RSS 提要。
请看下面的 RSS 文档:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>91xjr Home Page</title>
<link>https://www.91xjr.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>https://www.91xjr.com/xml/xml_rss.html</link>
<description>New RSS tutorial on 91xjr</description>
</item>
</channel>
</rss>
如前所述,<channel> 元素描述 RSS 提要,并具有三个必需的子元素:
<channel> 元素通常包含一个或多个<item> 元素。每个 <item> 元素定义 RSS 提要中的一篇文章或"story"。
此外,<channel> 还有几个可选的子元素。我们将在下面解释最重要的一些。
<category> 子元素用于指定 Feed 的类别。
<category> 元素使 RSS 聚合器可以根据类别对站点进行分组。
上述 RSS 文档的类别可以是:
<category>Web development</category>
<copyright> 子元素通知有关受版权保护的材料。
上述 RSS 文档的版权可能是:
<copyright>2006 Refsnes Data as. All rights reserved.</copyright>
<image> 子元素允许在聚合器呈现提要时显示图片。
<image> 元素具有三个必需的子元素:
上面的 RSS 文档的图片可以是:
<image>
<url>https://www.91xjr.com/images/logo.gif</url>
<title>91xjr.com</title>
<link>https://www.91xjr.com</link>
</image>
<language> 子元素用于指定用于编写文档的语言。
<language> 元素使 RSS 聚合器可以根据语言对站点进行分组。
上述 RSS 文档的语言可以是:
<language>en-us</language>
每个 <item> 元素定义 RSS 提要中的一篇文章或"story"。
请看下面的 RSS 文档:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>91xjr Home Page</title>
<link>https://www.91xjr.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>https://www.91xjr.com/xml/xml_rss.html</link>
<description>New RSS tutorial on 91xjr</description>
</item>
</channel>
</rss>
如前所述,每个 <item> 元素定义 RSS 提要中的一篇文章或 "story"。
<item> 元素具有三个必需的子元素:
此外,<item> 还有几个可选的子元素。我们将在下面解释最重要的一些。
<author> 子元素用于指定项目作者的电子邮件地址。
笔记:为了防止垃圾邮件,一些开发人员不包含 <author> 元素。
上面 RSS 文档中的项目的作者可能是:
<author>hege@refsnesdata.no</author>
<comments> 子元素允许项目链接到有关该项目的注释。
上面 RSS 文档中该项目的注释可以是:
<comments>https://www.91xjr.com/comments</comments>
<enclosure> 子元素允许将媒体文件包含在项目中。
<enclosure> 元素具有三个必需属性:
上述 RSS 文档中的项目中包含的媒体文件可以是:
<enclosure url="https://www.91xjr.com/xml/rss.mp3"
length="5000" type="audio/mpeg" />
如果其他人无法访问 RSS 文档,那么它就毫无用处。
现在是时候将您的 RSS 文件发布到网络上了。步骤如下:
1. 为您的 RSS 文件命名。请注意,该文件必须具有 .xml 扩展名。
2. 验证您的 RSS 文件
3. 将 RSS 文件上传到 Web 服务器上的 Web 目录。
4.复制小橙子或者
按钮到您的网络目录。
5. 将橙色小"RSS" 或"XML" 按钮放在您将向全世界提供RSS 的页面上(例如,在您的主页上)。然后添加一个链接到链接到 RSS 文件的按钮。代码看起来像这样:
<a href="https://www.91xjr.com/xml/myfirstrss.xml">
<img src="https://www.91xjr.com/xml/pic_rss.gif" 宽度="36" 高度="14">
</a>。
6. 将您的 RSS 源提交到 RSS 源目录(您可以通过 Google 或 Yahoo 获取 "RSS Feed Directories")。笔记!您的 Feed 的网址不是您的主页,而是您的 Feed 的网址,例如 "https://www.91xjr.com/xml/myfirstrss.xml"。
7. 在主要搜索引擎中注册您的提要:
8. 更新您的提要 - 注册您的 RSS 提要后,您必须确保经常更新您的内容并且您的 RSS 提要始终可用。
确保 RSS 源按照您想要的方式工作的最佳方法是自行管理。
然而,这可能非常耗时,尤其是对于有大量更新的页面。
另一种方法是使用第三方自动 RSS。
对于只需要为个人网站提供 RSS 源的用户,提供内置 RSS 服务的一些最受欢迎的博客(网络日志)管理器包括:
RSS 阅读器用于阅读 RSS 源!
RSS 阅读器可用于许多不同的设备和操作系统。
有很多不同的 RSS 阅读器。有些作为 Web 服务工作,有些仅限于 Windows(或 Mac、PDA 或 UNIX):
提示:大多数浏览器都有内置的 RSS 阅读器。如果您访问提供 RSS 源的网站,您将看到 RSS 图标在地址栏或工具栏中。单击该图标可查看不同提要的列表。选择您想要阅读的提要。
点击小或者
您要阅读的 RSS 提要旁边的按钮。复制您在浏览器窗口中获得的 URL 并将其粘贴到 RSS 阅读器中。
"Element" 列中的链接指向有关每个特定元素的更多信息。
Element | Description |
---|---|
<category> | Optional. Defines one or more categories for the feed |
<cloud> | Optional. Register processes to be notified immediately of updates of the feed |
<copyright> | Optional. Notifies about copyrighted material |
<description> | Required. Describes the channel |
<docs> | Optional. Specifies a URL to the documentation of the format used in the feed |
<generator> | Optional. Specifies the program used to generate the feed |
<image> | Optional. Allows an image to be displayed when aggregators present a feed |
<language> | Optional. Specifies the language the feed is written in |
<lastBuildDate> | Optional. Defines the last-modified date of the content of the feed |
<link> | Required. Defines the hyperlink to the channel |
<managingEditor> | Optional. Defines the e-mail address to the editor of the content of the feed |
<pubDate> | Optional. Defines the last publication date for the content of the feed |
<rating> | Optional. The PICS rating of the feed |
<skipDays> | Optional. Specifies the days where aggregators should skip updating the feed |
<skipHours> | Optional. Specifies the hours where aggregators should skip updating the feed |
<textInput> | Optional. Specifies a text input field that should be displayed with the feed |
<title> | Required. Defines the title of the channel |
<ttl> | Optional. Specifies the number of minutes the feed can stay cached before refreshing it from the source |
<webMaster> | Optional. Defines the e-mail address to the webmaster of the feed |
Element | Description |
---|---|
<author> | Optional. Specifies the e-mail address to the author of the item |
<category> | Optional. Defines one or more categories the item belongs to |
<comments> | Optional. Allows an item to link to comments about that item |
<description> | Required. Describes the item |
<enclosure> | Optional. Allows a media file to be included with the item |
<guid> | Optional. Defines a unique identifier for the item |
<link> | Required. Defines the hyperlink to the item |
<pubDate> | Optional. Defines the last-publication date for the item |
<source> | Optional. Specifies a third-party source for the item |
<title> | Required. Defines the title of the item |