php rss 解析,php 读取rss (2)

meta content="text/html; charset=utf-8" http-equiv="Content-Type" ?php // 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://medcl.n

// 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://medcl.net/SinaRss.aspx?uid=1562882353';

//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 '

';

echo '

'.$c->lastBuildDate.'

';

$listhead = '

序号

标题

作者

类别

评论

时间

';

echo $listhead;

$k = 0;

foreach($c->item as $v) {

$k ++;

echo "

$k

$v->author

$v->category

$v->pubDate

";

}

echo '

';

} else {

exit('Failed to open xml file.');

}

?>

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值