您好,欢迎访问一九零五行业门户网

PHP利用RSS订阅别处稿子

php利用rss订阅别处文章
这篇文章是接上篇利用php操作xml文件的。rss是基于xml的一种形式,它的具体规范如下(我们以截取的新浪rss订阅频道的格式来看):
输入:http://rss.sina.com.cn/news/world/focus15.xml   查看页面源码就可以看到rss的结构:
http://news.sina.com.cn/world http://www.sinaimg.cn/home/deco/2009/0330/logo_home_news.gif http://news.sina.com.cn/491/2008/0827/1.html zh-cn www.sina.com.cn 5 sat, 22 dec 2012 05:32:05 gmt http://go.rss.sina.com.cn/redirect.php?url=http://news.sina.com.cn/w/2012-12-22/120825871683.shtml www.sina.com.cn http://go.rss.sina.com.cn/redirect.php?url=http://news.sina.com.cn/w/2012-12-22/120825871683.shtml sat, 22 dec 2012 04:08:09 gmt
具体规范信息是代表什么意思,根据标签的内容我们就可以很容易的知道,下面我们写一个rss.php来读取这个xml,从而获取这上面的文章:
xml the example of rss channel->item as $item) { print(); print(link'>); print($item->title); print(); print(); }?>
注意这个函数:simplexml_load_file() ; 它既可以读本地的xml文件,也可以读网络上的xml。
运行结果:
ok, that's  all ....    天道酬勤!!
其它类似信息

推荐信息