我使用此代码在我的网站中显示新闻,但我总是为它显示的每条新闻得到这个,我不知道为什么会这样,有人可以帮忙吗?
$xml = simplexml_load_file('https://news.google.com.mx/news/feeds?hl=es&gl=mx&q=realmadrid&um=1&ie=UTF-8&output=rss');
print_r($xml);
foreach ($xml as $status) {
$description = $status->item->description;
echo "$description <br> ";
}
在显示每条新闻后我总是得到这个,我知道我正在使用 print_r,但没有 print_r 它只是显示第一条新闻,请帮助:
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [generator] => NFE/1.0 [title] => realmadrid: Google Noticias [link] => http://news.google.com.mx/news?gl=mx&pz=1&ned=es_mx&hl=es&q=realmadrid [language] => es [webMaster] => news-feedback@google.com [copyright] => ©2012 Google [pubDate] => Sun, 22 Apr 2012 01:00:21 GMT [lastBuildDate] => Sun, 22 Apr 2012 01:00:21 GMT [image] => SimpleXMLElement Object ( [title] => realmadrid: Google Noticias [url] => https://ssl.gstatic.com/news/img/logo/es_mx/news.gif [link] => http://news.google.com.mx/news?gl=mx&pz=1&ned=es_mx&hl=es&q=realmadrid ) [item] => Array ( [0] => SimpleXMLElement Object ( [title] => El Real Madrid apuntilla al Barça en el Camp Nou (1-2) - Republica.com (blog) [link] => http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGDpztvnga7JP035sqyCqZUrp_Elw&url=http://www.republica.com/2012/04/20/barca-realmadrid-2_482059/ [guid] => tag:news.google.com,2005:cluster=http://www.republica.com/2012/04/20/barca-realmadrid-2_482059/ [pubDate] => Sat, 21 Apr 2012 21:19:44 GMT [description] =>