<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mettere condizione a simplexml se non si carica]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, lo script per leggere un xml con simplexml è questo:</p>
<pre><code class="language-php">$dato="http://www.xxxx/blog/feed/";

    $xml = simplexml_load_file($dato);
    

      foreach($xml-&gt;channel as $channel)  
      {
    
          foreach($channel as $item){
              
                      echo '&lt;div id="pette" style="float:left; width:830px; height:auto; margin-bottom:10px;"&gt;&lt;strong&gt;'.$item-&gt;title.'&lt;/strong&gt;'.$item-&gt;description.'&lt;/div&gt;';

          }

      }

?&gt;
</code></pre>
<p dir="auto">A volte succede che non carica il feed e mi blocca tutto, come posso mettere una condizione perchè non accada questo ?<br />
Ovvero : se non carica xml carica un messaggio...</p>
]]></description><link>https://dev.connect.gt/topic/120631/mettere-condizione-a-simplexml-se-non-si-carica</link><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 08:57:35 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/120631.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Feb 2010 12:49:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mettere condizione a simplexml se non si carica on Wed, 17 Feb 2010 20:02:01 GMT]]></title><description><![CDATA[<p dir="auto">Potresti provare con la funzione <a href="http://php.net/manual/en/function.stream-set-timeout.php" rel="nofollow ugc">stream_set_timeout</a>.</p>
]]></description><link>https://dev.connect.gt/post/889607</link><guid isPermaLink="true">https://dev.connect.gt/post/889607</guid><dc:creator><![CDATA[samyorn]]></dc:creator><pubDate>Wed, 17 Feb 2010 20:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to Mettere condizione a simplexml se non si carica on Mon, 08 Feb 2010 10:44:57 GMT]]></title><description><![CDATA[<p dir="auto">Grazie, peroò mi resta sempre il timeout di base di php... quindi prima di verificare la funzione aspetta 30 secondi</p>
<pre><code>[[URL="http://www.radiocompany.com/function.simplexml-load-file"]function.simplexml-load-file[/URL]]:  failed to open stream: Operation timed out in
</code></pre>
]]></description><link>https://dev.connect.gt/post/889610</link><guid isPermaLink="true">https://dev.connect.gt/post/889610</guid><dc:creator><![CDATA[pettedemon]]></dc:creator><pubDate>Mon, 08 Feb 2010 10:44:57 GMT</pubDate></item><item><title><![CDATA[Reply to Mettere condizione a simplexml se non si carica on Sun, 07 Feb 2010 10:23:51 GMT]]></title><description><![CDATA[<p dir="auto">Ciao pettedemon, potresti provare così:</p>
<pre><code class="language-php">$dato="http://www.xxxx/blog/feed/";

$xml = simplexml_load_file($dato);
if ($xml !== FALSE)
{
      foreach($xml-&gt;channel as $channel)  
      {
    
          foreach($channel as $item){
              
                      echo '&lt;div id="pette" style="float:left; width:830px; height:auto; margin-bottom:10px;"&gt;&lt;strong&gt;'.$item-&gt;title.'&lt;/strong&gt;'.$item-&gt;description.'&lt;/div&gt;';

          }

      }
}
else
{
  echo "Messaggio d'errore.";
}
?&gt;
</code></pre>
<p dir="auto"><img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=2190ae3dadd" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/889608</link><guid isPermaLink="true">https://dev.connect.gt/post/889608</guid><dc:creator><![CDATA[samyorn]]></dc:creator><pubDate>Sun, 07 Feb 2010 10:23:51 GMT</pubDate></item></channel></rss>