RSS文件格式分析

RSS1.0和2.0所包含的核心的信息相同,但是其中的结构有所区别:

RSS中的标签详细介绍:

|-rdf:RDF/rss				RSS1.0/2.0的根元素
<!--rss还包含一个强制版本属性用以表示所用的RSS的准确格式,RSS1.0文档有名字空间限定,RSS2.0的文档就没有-->
	|-channel			频道		必备
		|-title		频道名称		必备
		|-link		频道的URL		必备
		|-description	频道的描述		必备
		|-image		指定一个 GIF或JPEG或PNG图片,用以与频道一起显示
			|-url			图片的url				必备 
			|-title			图片的标题,alt属性		必备 
			|-link			网站url(常以频道的url)	必备 
			|-description		用于link的title属性
			|-width			图片的宽度(象素为单位)	可选	最大144,默认88 
			|-height		图片的高度(象素为单位)	可选 	最大400,默认3
		|-textInput		指定一个text输入框供用户输入,具体信息及功能未定。
			|-title		Submit按钮的标签		必备 
			|-description	解释text输入区		必备 
			|-name		Textarea对象的名字 		必备 
			|-link		处理提交的请求的cgi程序	必备
		|-item				
		<!--在RSS1.0中,title和link是必须的,description是可选的。而在RSS2.0中,title或description必须提供其中的一个-->
		<!--1.0和2.0都有的标签-->
		
		|-language	频道文章所用语言
		|-copyright	频道内容的版权说明
		|-managingEditor	责任编辑的email
		|-category	指定频道所属的类别
		|-pubDate	频道内容发布日期,格式遵循RFC822格式
		<!--RSS2.0中扩展的,不过RSS1.0允许通过定义在单独的XML名字空间中的可扩展元素来创建这种类型的元数据,这两种格式在结构上的主要区别是其item、image和textinput节点的表示形式。RSS1.0中,channel元素包含对item、image和textinput节点的引用,这些节点存在于channel节点本身之外。这样在channel和所引用的节点之间建立了一种RDF关联channel元素与一个image元素以及两个item元素关联。RSS2.0中item元素只是在channel元素中连续排放。item元素包含实际的新闻项信息。-->
		
		|-webMaster	网站管理员email
		|-generator	生成该频道的程序名
		|-lastBuildDate	频道内容最后的修改日期
		|-docs		指向该RSS文件所用格式说明的URL
		|-ttl		有效期,用以指明该频道可被缓存的最长时间分钟为单位
		|-rating		这个频道的分级(主要指成人、限制、儿童等
		|-skipHours	提示新闻聚合器,那些小时时段它可以跳过。
		|-skipDays	提示新闻聚合器,那些天它可以跳过。

 RSS1.0例子:

<?xml version="1.0"?>
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns="http://purl.org/rss/1.0/">
	<channel rdf:about="http://www.xml.com/xml/news.rss">
		<title>XML.com</title>
		<link>http://xml.com/pub</link>
		<description>XML.com features a rich mix of information and services for the XML community. </description>
		<image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" />
		<items>
			<rdf:seq>
				<rdf:li resource="http://xml.com/pub/2000/08/09/xslt/xslt.html" />
				<rdf:li resource="http://xml.com/pub/2000/08/09/rdfdb/index.html" />
			</rdf:seq>
		</items>
		<textinput rdf:resource="http://search.xml.com" />
	</channel>
	<image rdf:about="http://xml.com/universal/images/xml_tiny.gif">
		<title>XML.com</title>
		<link>http://www.xml.com</link>
		<url>http://xml.com/universal/images/xml_tiny.gif</url>
	</image>
	<item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html">
		<title>Processing Inclusions with XSLT</title>
		<link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link>
		<description>Processing document inclusions with general XML tools can be problematic. This article proposes a way of preserving inclusion information through SAX-based processing.</description>
	</item>
	<item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html">
		<title>Putting RDF to Work</title>
		<link>http://xml.com/pub/2000/08/09/rdfdb/index.html</link>
		<description>Tool and API support for the Resource Description Framework is slowly coming of age. Edd Dumbill takes a look at RDFDB,one of the most exciting new RDF toolkits. </description>
	</item>
	<textinput rdf:about="http://search.xml.com">
		<title>Search XML.com</title>
		<description>Search XML.com's XML collection</description>
		<name>s</name>
		<link>http://search.xml.com</link>
	</textinput>
</rdf:rdf>

 

RSS2.0例子:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title>新闻中心-国内焦点新闻</title>
		<image>
			<title>新闻中心-国内焦点</title>
			<link>http://news.sina.com.cn/china</link>
			<url>http://image2.sina.com.cn/dy/gn/in10.jpg</url>
		</image>
		<description>国内焦点新闻列表</description>
		<link>http://news.sina.com.cn/china/index.shtml</link>
		<language>zh-cn</language>
		<!-- 当RSS文件为自动创建时多存在此节点(RSS文件由什么创建) -->
		<generator>WWW.SINA.COM.CN</generator>
		<!-- (ttl = time to live) 在刷新前当前RSS在cache中可以保存多长时间(分钟)-->
		<ttl>5</ttl>
		<copyright>Copyright 1996 - 2005 SINA Inc. All Rights Reserved</copyright>
		<pubdate>Wed, 26 Apr 2006 01:45:05 GMT</pubdate>
		<category /><!-- 一条新闻 -->
		<item>
			<title>xxxxxxx</title>
			<link>http://news.sina.com.cn/c/l/2006-04-26/08029720281.shtml</link>
			<author>WWW.SINA.COM.CN</author>
			<!-- guid>GUID=Globally Unique Identifier 为当前新闻指定一个全球唯一标示 -->
			<guid>http://news.sina.com.cn/c/l/2006-04-26/08029720281.shtml</guid>
			<category>xxxxxxx</category>
			<pubdate>Wed, 26 Apr 2006 00:02:53 GMT</pubdate>
			<comments/>
			<description>xxxxxxxx</description>
		</item>
	</channel>
</rss>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值