当前位置: 首页 > 网络学院 > XML相关教程 > RSS > RSS 语法
The syntax rules of RSS 2.0 are very simple and very strict. The rules are very easy to learn, and very easy to use.
RSS 2.0 的语法很简单,也很严格。这些规则很容易学习,也很容易使用。
RSS is used to share content between websites.
RSS 用于在网站间分享信息。
With RSS, you register your content with companies called aggregators.
使用 RSS,您在名为聚合器的公司注册您的内容。
So, to be a part of it: First, create an RSS document and save it with an .xml extension. Then, upload the file to your website. Next, register with an RSS aggregator. Each day the aggregator searches the registered websites for RSS documents, verifies the link, and displays information about the feed so clients can link to documents that interests them.
作为他的一部分,创建一个 RSS 文档,然后使用 .xml 后缀来保存它。然后把此文件上传导您的网站。接下来,通过一个 RSS 聚合器来注册。每天,聚合器都会到被注册的网站搜索 RSS 文档,校验其链接,并显示有关 feed 的信息,这样客户就能够链接到使他们产生兴趣的文档。
Tip: Read our RSS Publishing chapter to view free RSS aggregation services.
提示:请在 RSS 发布 这一节浏览免费的 RSS 聚合器服务。
RSS documents use a self-describing and simple syntax.
RSS文档使用一种简单的自我描述简单语法。
Let's look at a simple RSS document:
让我们看一个简单的 RSS 文档:
<?xml version="1.0" encoding="ISO-8859-1" ?> <channel> </rss> |
The first line in the document - the XML declaration - defines the XML version and the character encoding used in the document. In this case the document conforms to the 1.0 specification of XML and uses the ISO-8859-1 (Latin-1/West European) character set.
文档中的第一行:XML 声明 - 定义了文档中使用的 XML 版本和字符编码。此例子遵守 1.0 规范,并使用 ISO-8859-1 (Latin-1/West European) 字符集。
The next line is the RSS declaration which identifies that this is an RSS document (in this case, RSS version 2.0).
下一行是标识此文档是一个 RSS 文档的 RSS 声明(此例是 RSS version 2.0)。
The next line contains the <channel> element. This element is used to describe the RSS feed.
下一行含有 <channel> 元素。此元素用于描述 RSS feed。
The <channel> element has three required child elements:
<channel> 元素有三个必需的子元素:
Each <channel> element can have one ore more <item> elements.
每个 <channel> 元素可拥有一个或多个 <item> 元素。
Each <item> element defines an article or "story" in the RSS feed.
每个 <item> 元素可定义 RSS feed 中的一篇文章或 "story"。
The <item> element has three required child elements:
<item> 元素拥有三个必需的子元素:
Finally, the two last lines close the <channel> and <rss> elements.
最后,后面的两行关闭 <channel> 和 <rss> 元素。
The syntax for writing comments in RSS is similar to that of HTML:
在 RSS 中书写注释的语法与 HTML 的语法类似:
<!-- This is an RSS comment --> |
Because RSS is XML, keep in mind that:
因为RSS是XML,所以要记住: