Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP e XML — Google Weather API problem with language selection
    primarykey
    data
    text
    <p>I want show weather information from xml to this URL: <a href="http://www.google.com/ig/api?weather=roma&amp;hl=it" rel="nofollow">http://www.google.com/ig/api?weather=roma&amp;hl=it</a> using this script:</p> <pre><code>&lt;? $xml = simplexml_load_file('http://www.google.com/ig/api?weather=roma&amp;hl=it'); $information = $xml-&gt;xpath("/xml_api_reply/weather/forecast_information"); $current = $xml-&gt;xpath("/xml_api_reply/weather/current_conditions"); $forecast_list = $xml-&gt;xpath("/xml_api_reply/weather/forecast_conditions"); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Google Weather API&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;?= print $information[0]-&gt;city['data']; ?&gt;&lt;/h1&gt; &lt;h2&gt;Today's weather&lt;/h2&gt; &lt;div class="weather"&gt; &lt;img src="&lt;?= 'http://www.google.com' . $current[0]-&gt;icon['data']?&gt;" alt="weather"?&gt; &lt;span class="condition"&gt; &lt;?= $current[0]-&gt;temp_f['data'] ?&gt;° F, &lt;?= $current[0]-&gt;condition['data'] ?&gt; &lt;/span&gt; &lt;/div&gt; &lt;h2&gt;Forecast&lt;/h2&gt; &lt;? foreach ($forecast_list as $forecast) : ?&gt; &lt;div class="weather"&gt; &lt;img src="&lt;?= 'http://www.google.com' . $forecast-&gt;icon['data']?&gt;" alt="weather"?&gt; &lt;div&gt;&lt;?= $forecast-&gt;day_of_week['data']; ?&gt;&lt;/div&gt; &lt;span class="condition"&gt; &lt;?= $forecast-&gt;low['data'] ?&gt;° F - &lt;?= $forecast-&gt;high['data'] ?&gt;° F, &lt;?= $forecast-&gt;condition['data'] ?&gt; &lt;/span&gt; &lt;/div&gt; &lt;? endforeach ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But the script does not show any output, if I delete the language specification (&amp;hl=it) from simplexml_load_file's parameters, it works.</p> <p>Error_log_php Output:</p> <pre><code>[24-Jun-2011 11:12:53] PHP Warning: simplexml_load_file() [&lt;a href='function.simplexml-load-file'&gt;function.simplexml-load-file&lt;/a&gt;]: http://www.google.com/ig/api?weather=roma&amp;amp;hl=it:1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xE0 0x3A 0x20 0x35 in /home/site/public_html/test.php on line 2 [24-Jun-2011 11:12:53] PHP Warning: simplexml_load_file() [&lt;a href='function.simplexml-load-file'&gt;function.simplexml-load-file&lt;/a&gt;]: ialmente nuvoloso&amp;quot;/&amp;gt;&amp;lt;temp_f data=&amp;quot;81&amp;quot;/&amp;gt;&amp;lt;temp_c data=&amp;quot;27&amp;quot;/&amp;gt;&amp;lt;humidity data=&amp;quot;Umidit in /home/site/public_html/test.php on line 2 [24-Jun-2011 11:12:53] PHP Warning: simplexml_load_file() [&lt;a href='function.simplexml-load-file'&gt;function.simplexml-load-file&lt;/a&gt;]:^ in /home/site/public_html/test.php on line 2 [24-Jun-2011 11:12:53] PHP Fatal error: Call to a member function xpath() on a non-object in /home/site/public_html/test.php on line 3 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload