当前位置: 首页 > 网络学院 > XML相关教程 > RSS > RSS <item> 元素

RSS
RSS 介绍
RSS 历史
RSS 语法
RSS <channel> 元素
RSS <item> 元素
RSS 发布 Feed
RSS 解读 Feed

RSS <item> 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 535 ::
收藏到网摘: n/a

Each <item> element defines an article or "story" in the RSS feed.
每个 <item> 元素可定义 RSS feed 中的一篇文章或 "story"。


The <item> Element
<item> 元素

Look at the following 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>
</channel>
</rss>

As mentioned before, 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> 元素拥有三个必需的子元素:

Furthermore, there are several optional child elements of <item>. We will explain the most important ones below.
此外,存在若干个 <item> 的可选的子元素,我们会在下面介绍最重要的几个。


The <author> Element
<author>元素

The <author> child element is used to specify the e-mail address of the author of an item.
<author> 子元素用于规定一个项目的作者的电子邮件地址。

Note: To prevent spam e-mails, some developers do not include the <author> element.
注意:为了防止垃圾邮件,一些开发者不会使用这个 <author> 元素。

The author of the item in the RSS document above could be:
上面的 RSS 文档中项目的作者可能是:

<author>[email protected]</author>

 


The <comments> Element
<comments>元素

The <comments> child element allows an item to link to comments about that item.
<comments> 子元素允许把一个项目连接到有关此项目的注释。

A comment of the item in the RSS document above could be:
上面的 RSS 文档中项目的注释可能这样的:

<comments>http://www.w3schools.com/comments</comments>

 


The <enclosure> Element
<enclosure>元素

The <enclosure> child element allows a media-file to be included with an item.
<enclosure> 子元素允许将一个媒体文件导入一个项中。

The <enclosure> element has three required attributes:
<enclosure> 元素有三个必需的属性:

  • url - Defines the URL to the media file
    • URL -定义指向此媒体文件的 URL
  • length - Defines the length (in bytes) of the media file
    • length -定义此媒体文件的长度(字节)
  • type - Defines the type of media file
    • type -定义媒体文件的类型

A media-file included in the item in the RSS document above could be:
在上面的 RSS 文档中,被包含在项目中的媒体文件可能是这样的:

<enclosure url="http://www.w3schools.com/rss/rss.mp3
length="5000" type="audio/mpeg" />

 


RSS <item> Reference
RSS <item>参数

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
必要参数。定义此项目的标题

评论 (0) All

登陆 | 还没注册?