Jump to content

simplexml will not load


jackjames

Recommended Posts

I'm pretty new to php.  But the below script should get news articles from google news rss.  It is failing to load the simplexml and returns false.  Any idea why?

 

$url = "http://news.google.com/news?geo=90210";
if ($xml = @simplexml_load_file($url))
					{
						for ($i=0; $i<4; $i++)
						{
							$item= $xml->channel->item[$i];

							$link= '<a href = "'.(string) $item->link.'", target= "_blank">'.(string) substr($item->title, 0, 50).'...</a><br />';
							$news[]= $link;
						}
					}

Link to comment
https://forums.phpfreaks.com/topic/232299-simplexml-will-not-load/
Share on other sites

Thanks for your quick reply.  When removed (@) I get many errors, below is an example of some of them.  I've removed my home directory by line of code refers to: if ($xml = simplexml_load_file($url))

 

Warning: simplexml_load_file() [function.simplexml-load-file]: http://news.google.com/news?geo=02138:10: parser error : xmlParseEntityRef: no name in

 

Warning: simplexml_load_file() [function.simplexml-load-file]: try{var pageT=null;GLOBAL_window.chrome&&GLOBAL_window.chrome.csi&&(pageT=Math.f in

 

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in

 

Warning: simplexml_load_file() [function.simplexml-load-file]: http://news.google.com/news?geo=02138:10: parser error : EntityRef: expecting ';' in

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.