大马资讯论坛 - 马来西亚中文资讯平台

 找回密码
 注册
搜索
打印 上一主题 下一主题

[教学] SimpleXmlElement的enclosure一直警告Node no longer exists

[复制链接]
跳转到指定楼层
1#
发表于 2013-8-3 23:45:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Php SimpleXmlElement的enclosure一直警告Node no longer exists
原因是不是每个item都有enclosure,系统就警告啦,以下的代码可以解决这个问题
  1. if (isset($xml->channel->item[$i]->enclosure)){
  2.         if (isset($xml->channel->item[$i]->enclosure->attributes()->url)){
  3.                 $img_url = $xml->channel->item[$i]->enclosure->attributes()->url;
  4.                 echo $img_url . '<br>';
  5.         }
  6. }
复制代码

手机版|大马资讯论坛  

GMT+8, 2024-4-26 14:46 , Processed in 0.023916 second(s), 13 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表