外部API使用以下XML回复我
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
<soapenv:Body>
<res:ResultMsg xmlns:res='http://cps.huawei.com/cpsinterface/result'>
<![CDATA[
<?xml version='1.0' encoding='utf-8'?><Result><ResultParameters><ResultParameter><Key>FailedReason</Key><Value>The value 611015125123 of the CNIC parameter is incorrect, failed to authenticate the parameter.</Value></ResultParameter></ResultParameters><ResultCode>2002</ResultCode><ResultType>0</ResultType><OriginatorConversationID>20180904165750</OriginatorConversationID><ResultDesc>Transaction information is invalid.</ResultDesc><TransactionID>000000000000</TransactionID><ConversationID>AG_20180904_00007be9004e56992e5f</ConversationID></Result>]]>
</res:ResultMsg>
</soapenv:Body>
</soapenv:Envelope>
我已参考之前的答案并尝试过
$xml = simplexml_load_string($xml_string, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
exit (var_dump($array));
还尝试从有效载荷和
中删除CDATA标签$xml_string = str_replace('<![CDATA[','',$xml_string);
$xml_string=str_replace(']]>','',$xml_string);
但这也无济于事,曾经尝试了
How to get CDATA texts from XML by id in tags 和许多其他问题。 请在投票前留下一分钟。