时间:2016-02-24 21:38 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【用PHP读取RSS内容,实现与BLOG的同步】,下面是详细的分享!
用PHP读取RSS内容,实现与BLOG的同步
以下为引用的内容:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">// The file test.xml contains an XML document with a root element
// and at least an element /[root]/title.
$xmlfile=date('YmdH').'.xml';
$sourcexml='http://blog.eaxi.com/rss.xml';
//die($xmlfile);
if( !file_exists($xmlfile) ) {
echo '你是第一次访问本系统。正在初始化...';
$str=@file($sourcexml) or die('加载文件时出错。');
$str=join('',$str);
$fp=fopen($xmlfile,'w') or die('写缓存失败!');
fputs($fp,$str);
fclose($fp);
echo "初始化完毕。";
}
if (file_exists($xmlfile)) {
$xml=simplexml_load_file($xmlfile);
//print_r($xml);
$c=&$xml->channel;
echo '</meta>
</code></p>
<h2><a title="" href=http://www.chinaz.com/program/2008/1017/"'.$c->link.'">'.$c->title.'</a></h2>
<p>';
echo '</p>
<h5>'.$c->lastBuildDate.'</h5>
<hr />
<p>';
$listhead='</p>
<table border="1">
<tbody>
<tr>
<td>序号</td>
<td>标题</td>
<td>作者</td>
<td>类别</td>
<td>评论</td>
<td>时间</td>
</tr>
';
echo $listhead;
$k=0;
foreach($c->item as $v) {
$k ++;
echo "
<tr>
<td>$k</td>
<td><a title="$v->title" href=http://www.chinaz.com/program/2008/1017/"$v->link">$v->title</a></td>
<td>$v->author</td>
<td>$v->category</td>
<td><a title="点击发表评论" href=http://www.chinaz.com/program/2008/1017/"$v->comments">评论</a></td>
<td>$v->pubDate</td>
</tr>
";
}
echo '
</tbody>
</table>
<p>';
} else {
exit('Failed to open xml file.');
}
?>
以上所分享的是关于用PHP读取RSS内容,实现与BLOG的同步,下面是编辑为你推荐的有价值的用户互动:
相关问题:用C#调用CMD时,如何实现同步输出结果,而不是等命...
答:思路: 同时执行时,需要顺序执行,如果需要同时输出结果,需要让cmd异步执行,同时将结果通过代理方式传递到界面. 具体内容请参考以下博文 http://blog.csdn.net/irwin_chen/article/details/7430551 关注代理方法: CmdProcess.OutputDataReceived +... >>详细
相关问题:用java实现从指定文件的指定行数开始往后读取数据...
答:具体思路: ①按行读取文件 ②将每行存到List中 ③取具体行或行区间时,读取List即可 PS:如果看着好,记得加分!good luck!~有问题可百度Hi我!~ >>详细
相关问题:如何使网页页面和数据库同步刷新?用php,jsp什么...
答:你可以使用ajax,不间断的请求服务器中新添加的数据,并插入到页面中 >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
