<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:body>
<ns1:mbillcommandresponse xmlns:ns1="http://www.mysoap.com/SoapService/">
<ReturnValues>
<name>status</name>
<value>TEHNICAL_ERROR</value>
</ReturnValues>
<ReturnValues>
<name>description</name>
<value>Please contact your administrator</value>
</ReturnValues>
</ns1:mbillcommandresponse>
</soapenv:body>
</soapenv:envelope>
我在CURL响应中获得了以上内容。这是我的PHP代码:
$response = curl_exec($ch);
$xml = simplexml_load_string($response);
//$result = $xml->xpath('//name'); //echo "<pre>"; print_r($result); exit;
$xml->registerXPathNamespace('ns1', 'http://www.mysoap.com/SoapService/');
foreach ($xml->xpath('//returnvalues') as $item) {
$json = json_encode($item);
$convrt_arr = json_decode($json, true);
break;
}
print_r($json); exit;
在我上述的代码中,我得到了一个空的json。你能帮忙看看吗?
{"name":"status","value":"TEHNICAL_ERROR"}
。 - Marcoreturnvalues
数据。 - Chinmay235