PHP / SimpleXML - Why does Simplexml_load_string() fail to parse Google Weather API xml in Chinese (

Posted by John Himmelman on Stack Overflow See other posts from Stack Overflow or by John Himmelman
Published on 2010-05-24T18:26:47Z Indexed on 2010/05/24 18:41 UTC
Read the original article Hit count: 511

Filed under:
|
|

I'm trying to load parse a Google Weather API response (chinese response). Here is the API call..

http://www.google.com/ig/api?weather=11791&hl=zh-CN

// This code fails with the following error
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=11791&hl=zh-CN');

( ! ) 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

Why does loading this response fail? How do I encode/decode the response so that simplexml loads it properly?

© Stack Overflow or respective owner

Related posts about php

Related posts about simplexml