<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>一坨博客 &#187; PHP Dev</title>
	<atom:link href="http://blog.wupei.name/category/php-development/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.wupei.name</link>
	<description>别跟我装B, 你其实啥也不知道</description>
	<lastBuildDate>Tue, 22 Jun 2010 16:43:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Zend_Feed打造Feed Reader</title>
		<link>http://blog.wupei.name/build-feed-reader-with-zend-feed.html</link>
		<comments>http://blog.wupei.name/build-feed-reader-with-zend-feed.html#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:48:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Dev]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://blog.wupei.name/?p=19</guid>
		<description><![CDATA[作者：Haohappy 来源：http://www.phpeye.com]PHPEye.com 最后更新：2006-12-19 15:41:24 相信对于很多人来说，通过Bloglines,Google Reader这些阅读器订阅和浏览Blog已经是网络生活的一部份。如果你打算自己打造一个好用的Feed Reader，不妨试试Zend_Feed这个好用的类库。 首先大概的原理是读取Blog的RSS或Atom Feed，得到XML文件，解析该文件得到数据。为了加快浏览速度，我们通常需要把得到数据保存到本地数据库中。 以上目的分解成技术步骤有以下三步： 1。读取RSS。　你可以使用现成的函数或者专业的RSS类库（这种类库一般还提供更多丰富的功能），也可以自己模拟HTTP来抓取； 在PHP中，使用简单的比如file_get_contents()函数就可以方便而且高效地抓取文件，但有时候可能RSS文件是不能直接获取的，比如获取你的Bloglines帐号中订阅的RSS，那么可能你还需要提交一些参数或者通过HTTP认证之类，这时可用模拟HTTP的方法，比如下面代码使用了PEAR::Http_Request： function getRSS($username,$password,$s,$n=0){ $url = "http://rpc.bloglines.com/getitems?s=".$s."&#38;n=".$n; $req = &#38; new HTTP_Request($url); $req-&#62;setBasicAuth($username,$password); $req-&#62;sendRequest(); $blogContent = $req-&#62;getResponseBody(); return $blogContent; } 填入你的Bloglines帐号和密码，利用这个函数你就可以得到RSS文件。 2。解析XML　RSS文件遵循一定规范，你可以自己写个函数来解析，没什么难度，但有点繁琐。 3。将解析得到的数据入库。 好了，大概知道了要做的工作，你会发现虽然都不难，但是自己一个个实现比较麻烦，呵呵。这就是本文要介绍Zend_Feed的原因。 Zend_Feed是Zend Framework中的一个类库，我们完全可以把它单独拿出来使用。Zend_Feed高度封装，使用非常方便，例如读取一个RSS Feed: $channel = new Zend_Feed_Rss('http://rss.example.com/channelName'); echo $channel-&#62;title(); //遍历记录 foreach ($channel as $item) { echo $item-&#62;title() . "\n"; } 是不是非常简单？　读取和解析总共5行代码。 [...]]]></description>
		<wfw:commentRss>http://blog.wupei.name/build-feed-reader-with-zend-feed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
