Ciao a tutti, sto usando simplexml per leggere un feed rss di un blog creato in wordpress, lo script è questo
Codice PHP:
$dato="http://www.xxxx.it/blog/feed/";

    
$xml simplexml_load_file($dato);
      foreach(
$xml->channel as $channel)  
      {
          foreach(
$channel as $item){

  echo 
'<div id="pette" style="float:left; width:830px; height:auto; margin-bottom:10px;">[b]'.$item->title.'[/b]'.$item->description.'</div>';

            
          }

      } 
Ci sono dei momenti in cui non riesce a leggere il feed, vorrei mettere una condizione in modo che lo script se non riesce a caricare il feed mi lanci un messaggio del tipo : dati in aggiornamento.
Come posso fare ?

Questo è xml
codice:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog</title>
	<atom:link href="http://www.it/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www..it/blog</link>
	<description>Blog</description>
	<lastBuildDate>Thu, 04 Feb 2010 10:27:02 +0000</lastBuildDate>

	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>LaCie Coat e LaCie ForMoa, custodie per netbook, Macbook e iPad</title>

		<link>http://www.formoa-custodie-per-netbook-macbook-e-ipad/</link>
		<comments>http:d/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 10:22:43 +0000</pubDate>
		<dc:creator>PROnWeb</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[LaCie]]></category>
		<category><![CDATA[Netbook]]></category>

		<category><![CDATA[Nuove tecnologie]]></category>
		<category><![CDATA[Pc & Mac]]></category>
		<category><![CDATA[10.2"]]></category>
		<category><![CDATA[13"]]></category>
		<category><![CDATA[15"]]></category>
		<category><![CDATA[17]]></category>
		<category><![CDATA[antigraffio]]></category>
		<category><![CDATA[custodia]]></category>
		<category><![CDATA[custodie]]></category>

		<category><![CDATA[iPad]]></category>
		<category><![CDATA[LaCie Coat]]></category>
		<category><![CDATA[LaCie ForMoa]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[neoprene]]></category>

		<guid isPermaLink="false">http://www.it/blog/?p=2337</guid>
		<description><![CDATA[LaCie presenta le nuove linee di custodie LaCie Coat e LaCie ForMoa, dedicate a netbook, Macbook e iPad.]]></description


Condividi:





]]></content:encoded>

			<wfw:commentRss>http://www.</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>