/* 发送curl请求 */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
$output = curl_exec($ch);
curl_close($ch); print_r($output);echo "<br/>------------------------------------";
/* 转换编码*/
$output = mb_convert_encoding($output, 'UTF-8', 'GB2312');
$output = str_replace('GB2312', 'utf-8', $output);
/* 解析xml数据 */
$obj_x = new XMLReader();
$obj_x->XML($output);
$res_datas = $this->xml2assoc($obj_x);
$obj_x->close();
print_r($res_datas);
die;
已解决,原因是 XML格式字符串前有空格,导致解析失败.