首页 > 解决方案 > 字符串类型的 XML 变量问题 PHP

问题描述

请查看以下代码

$xml_string = "<?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>";

然后我得到变量的类型

$type=gettype($xml_string);

echo 字符串好。当我尝试回显实际值时,它只是打印出其中的一部分。

FailedReasonThe value 611015125123 of the CNIC parameter is incorrect, failed to authenticate the parameter.2002020180904165750Transaction information is invalid.000000000000AG_20180904_00007be9004e56992e5f]]>

为什么会发生这种奇怪的行为。我也尝试替换所有换行符,但没有帮助。任何提示表示赞赏。

标签: phparraysxmlstring

解决方案


我最后犯了一个愚蠢的错误,如果有人偶然发现这个问题,请回答。根据对我问题的评论,我有完整的数据,但由于标签,浏览器没有显示它。

 echo "<textarea>";
           echo $manual ;     
 echo "</textarea>";

做了这项工作。


推荐阅读