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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.