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的语法规则非常简单而且很严谨。这些语法规则易学易用。


How RSS Works
RSS如何运行

RSS is used to share content between websites.
RSS是用于网站之间的内容共享的。

With RSS, you register your content with companies called aggregators.
通过RSS,你是通过一个名为aggregators的组织来注册内容的。

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 aggregator进行注册。aggregator每天都会为RSS文档搜寻已注册过站点,检验其连接并显示与RSS相关的信息以帮助客户链接到他们感兴趣的内容。

Tip: Read our RSS Publishing chapter to view free RSS aggregation services.
提示:阅读我们的RSS章节,查看免费RSS aggregation服务。


An Example RSS document
RSS文件实例

RSS documents use a self-describing and simple syntax.
RSS文件使用自我描述(self-describing)和简单语法。

Let's look at a simple RSS document:
让我们看一下简单的RSS文件:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<title>W3Schools Home Page</title>
<link>http://www.w3schools.com</link>
<description>Free web building tutorials</description>

<item>
<title>RSS Tutorial</title>
<link>http://www.w3schools.com/rss</link>
<description>New RSS tutorial on W3Schools</description>

</item>
<item>
<title>XML Tutorial</title>
<link>http://www.w3schools.com/xml</link>
<description>New XML tutorial on W3Schools</description>

</item>
</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的版本和章节。所以此文件是符合XML1.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声明(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>元素含有3个必要子元素:

  • <title> - Defines the title of the channel (e.g. W3Schools Home Page)
    <title>-定义了channel的标题(如:W3POP主页)
  • <link> - Defines the hyperlink to the channel (e.g. http://www.w3pop.com)
    <link>-定义了到channel的超链接(如:http://www.w3pop.com
  • <description> - Describes the channel (e.g. Free web building tutorials) 
    <description>-描述了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>元素定义了一个项(article)或RSS Feed中的"story"。

The <item> element has three required child elements:
<item>元素含有3个必须子元素:

  • <title> - Defines the title of the item (e.g. RSS Tutorial) 
    <title>-定义了项的标题(比如RSS教程)
  • <link> - Defines the hyperlink to the item (e.g. http://www.w3pop.com/rss
    <link>-定义了到项上的超链接(如:http://www.w3pop.com/rss)
  • <description> - Describes the item (e.g. New RSS tutorial on W3Schools)
    <description>-定义了项(如:W3pop上的新RSS教程)

Finally, the two last lines close the <channel> and <rss> elements.
最后两行关闭了<channel> 和 <rss>元素。


Comments in RSS
RSS的注释

The syntax for writing comments in RSS is similar to that of HTML:
RSS中编写注释的语法与HTML相似。

<!-- This is an RSS comment -->


RSS is Written in XML
用XML编写RSS

Because RSS is XML, keep in mind that:
因为RSS是XML,所以要记住:

  • All elements must have a closing tag
    所有元素必须含有一个结束标签
  • Elements are case sensitive
    元素要区分大小写
  • Elements must be properly nested
    元素必须恰当嵌套
  • Attribute values must always be quoted
    必须引用属性值
     
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值