Originariamente inviato da Seso7
però usa al posto di fopen:
Codice PHP:
$xml = simplexml_load_file('percorso file xml');
//già che ci sono ti metto tutto....
foreach($xml->percorsodentroalfilexml->yweather:condition->attributes() as $text => $code => $temp => $date) {
echo $temp;
}
/* in percorsodentroalfilexml devi separare tutto il percorso con -> ad esempio se il xml è <a>[b]ciao[/b]<a> devi mettere $xml->a->b */
spero di esserti stato utile... se non ti funziona o vuoi qualche altro chiarimento chiedi....
ciao Seso7
mi sa che ho sbagliato qualcosa in percorsodentroalfilexml, cmq ad ogni modo io vorrei prendere la temperatura di questo file xml che e' di yahoo, ecco il codice completo:
codice:
<rss version="2.0">
−
<channel>
<title>Yahoo! Weather - Naples, IT</title>
−
<link>
http://us.rd.yahoo.com/dailynews/rss...TXX0052_c.html
</link>
<description>Yahoo! Weather for Naples, IT</description>
<language>en-us</language>
<lastBuildDate>Fri, 01 Dec 2006 11:20 pm CET</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Naples" region="" country="IT"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="kph"/>
<yweather:wind chill="9" direction="0" speed="3"/>
<yweather:atmosphere humidity="76" visibility="401" pressure="0" rising="0"/>
<yweather:astronomy sunrise="7:08 am" sunset="4:36 pm"/>
−
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
<link>http://weather.yahoo.com/</link>
−
<url>
http://us.i1.yimg.com/us.yimg.com/i/.../main_142b.gif
</url>
</image>
−
<item>
<title>Conditions for Naples, IT at 11:20 pm CET</title>
<geo:lat>40.85</geo:lat>
<geo:long>14.3</geo:long>
−
<link>
http://us.rd.yahoo.com/dailynews/rss...TXX0052_c.html
</link>
<pubDate>Fri, 01 Dec 2006 11:20 pm CET</pubDate>
<yweather:condition text="Fog" code="20" temp="9" date="Fri, 01 Dec 2006 11:20 pm CET"/>
−
<description>
Current Conditions:
Fog, 9 C
Forecast:
Fri - Mostly Clear. High: 17 Low: 6
Sat - PM Showers. High: 17 Low: 6
Full Forecast at Yahoo! Weather
(provided by The Weather Channel)
</description>
<yweather:forecast day="Fri" date="01 Dec 2006" low="6" high="17" text="Mostly Clear" code="33"/>
<yweather:forecast day="Sat" date="02 Dec 2006" low="6" high="17" text="PM Showers" code="39"/>
<guid isPermaLink="false">ITXX0052_2006_12_01_23_20_CET</guid>
</item>
</channel>
</rss>
Come modificao il codice che mi hai inviato tu?