Maison >développement back-end >tutoriel php >XML解析
array(2) {
["header"]=>
string(267) "HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=BDED717E8585DDA55A47EA1822C00E80; Path=/sdkproxy/; HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Language: en-GB
Content-Length: 103
Date: Sat, 24 Aug 2013 02:38:00 GMT
Connection: close"
["body"]=>
string(103) "
}
是一个web服务端的返回值
用 simplexml_load_string解析返回false,我都诧异了
['body']的内容如何转换成一个数组形式
$xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><error>0</error><message>-1100.0</message></response>"; $xml = simplexml_load_string($xml_string); //对象转换成数组,方便引用 $arr = (array)$xml; var_dump($arr);
$ar = simplexml_load_string($data['body']);
$ar = simplexml_load_string($data['body']);
我还不至于犯这个低级错误
不知道你会犯什么样的高级错误
$s = '<?xml version="1.0" encoding="UTF-8"?><response><error>0</error><message>-1100.0</message></response>';$xml = simplexml_load_string($s);print_r($xml);SimpleXMLElement Object
不知道你会犯什么样的高级错误
$s = '<?xml version="1.0" encoding="UTF-8"?><response><error>0</error><message>-1100.0</message></response>';$xml = simplexml_load_string($s);print_r($xml);SimpleXMLElement Object
贴出接收到的数据的序列化值
比如你接受的的数据在 $data 中,则
echo serialize($data);
贴出结果
贴出接收到的数据的序列化值
比如你接受的的数据在 $data 中,则
echo serialize($data);
贴出结果
a:2:{s:6:"header";s:267:"HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=96B4D5E802AEBBE6A1F92824C576690B; Path=/sdkproxy/; HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Language: en-GB
Content-Length: 103
Date: Sat, 24 Aug 2013 03:22:14 GMT
Connection: close";s:4:"body";s:103:"
我感觉是数据的问题
$s = 'a:2:{s:6:"header";s:267:"HTTP/1.1 200 OKServer: Apache-Coyote/1.1Set-Cookie: JSESSIONID=96B4D5E802AEBBE6A1F92824C576690B; Path=/sdkproxy/; HttpOnlyContent-Type: text/html;charset=UTF-8Content-Language: en-GBContent-Length: 103Date: Sat, 24 Aug 2013 03:22:14 GMTConnection: close";s:4:"body";s:103:"<?xml version="1.0" encoding="UTF-8"?><response><error>0</error><message>-1100.0</message></response>";}';$d = unserialize($s);$xml = simplexml_load_string(trim($d['body']));print_r($xml);SimpleXMLElement Object
$s = 'a:2:{s:6:"header";s:267:"HTTP/1.1 200 OKServer: Apache-Coyote/1.1Set-Cookie: JSESSIONID=96B4D5E802AEBBE6A1F92824C576690B; Path=/sdkproxy/; HttpOnlyContent-Type: text/html;charset=UTF-8Content-Language: en-GBContent-Length: 103Date: Sat, 24 Aug 2013 03:22:14 GMTConnection: close";s:4:"body";s:103:"<?xml version="1.0" encoding="UTF-8"?><response><error>0</error><message>-1100.0</message></response>";}';$d = unserialize($s);$xml = simplexml_load_string(trim($d['body']));print_r($xml);SimpleXMLElement Object