Note that there are some explanatory texts on larger screens.

plurals
  1. POSimplexml_load_string() fail to parse error
    text
    copied!<p>I'm trying to load parse a Google Weather API response (Chinese response).</p> <p><a href="http://www.google.com/ig/api?weather=11791&amp;hl=zh-CN" rel="nofollow noreferrer">Here</a> is the API call.</p> <pre><code>// This code fails with the following error $xml = simplexml_load_file('http://www.google.com/ig/api?weather=11791&amp;hl=zh-CN'); </code></pre> <blockquote> <p>( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xB6 0xE0 0xD4 0xC6 in C:\htdocs\weather.php on line 11</p> </blockquote> <p>Why does loading this response fail?</p> <p>How do I encode/decode the response so that <code>simplexml</code> loads it properly?</p> <p><strong>Edit:</strong> Here is the code and output.</p> <pre><code>&lt;?php $googleData = file_get_contents('http://www.google.com/ig/api?weather=11102&amp;hl=zh-CN'); $xml = simplexml_load_string($googleData); </code></pre> <blockquote> <p>( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xB6 0xE0 0xD4 0xC6 in C:\htdocs\test4.php on line 3 Call Stack Time Memory Function Location 1 0.0020 314264 {main}( ) ..\test4.php:0 2 0.1535 317520 simplexml_load_string ( string(1364) ) ..\test4.php:3</p> <p>( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: t_system data="SI"/> <p>( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\htdocs\test4.php on line 3 Call Stack Time Memory Function Location 1 0.0020 314264 {main}( ) ..\test4.php:0 2 0.1535 317520 simplexml_load_string ( string(1364) ) ..\test4.php:3</p> </blockquote>
 

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