我在确定使用哪种方法来显示从 XML 发送的图像时遇到问题。我收到以下 XML 响应:-
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<i18n:international xmlns:i18n="http://www.w3.org/2005/09/ws-i18n">
<i18n:locale>en_US</i18n:locale></i18n:international>
</soapenv:Header>
<soapenv:Body>
<get:GetCustAreaSnapshotResponseParam xmlns:get="http://tnb.com.my/CGIS/D/getcustareasnapshotcon">
<ResponseHdr>
<ns2:ResponseId xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">02946A91565A40210000013AB9B58E97</ns2:ResponseId>
<ns2:ResTransactionId xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">111112100334570</ns2:ResTransactionId>
<ns2:ProviderId xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">CGIS</ns2:ProviderId>
<ns2:ResTimestamp xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">2012-11-01T10:03:34.000+08:00</ns2:ResTimestamp>
<ns2:ResStatus xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">SUCC</ns2:ResStatus>
<ns2:MsgCode xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">IM-001</ns2:MsgCode>
<ns2:MsgDesc xmlns:ns2="http://www.tnb.com.my/CGIS/schemas/bsmfpro" xmlns:ns1="http://tnb.com.my/CGIS/D/getcustareasnapshotpro">Map Data Successfully Return to external Systems.</ns2:MsgDesc>
</ResponseHdr>
<ResGetCustAreaSnapshot>
<cmc:GetCustAreaSnapshot xmlns:cmc="http://tnb.com.my/CGIS/D/cmc_customermgnt">
<cmc:MAP_IMAGE_ZOOM1000>iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAYAAAB+TFE1AAAQJUlEQVR4nO3d3XbbthZGUbgj7w==</cmc:MAP_IMAGE_ZOOM1000>
<cmc:MAP_IMAGE_ZOOM2000>iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAYAAAB+TFE1AAAHoElEQVR4nO3d3XKaUBhA0UMn7w==</cmc:MAP_IMAGE_ZOOM2000>
<cmc:MAP_IMAGE_ZOOM4000>iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAYAAAB+TFE1AAAHCklEQVR4nO3dya6bMABAUVPl</cmc:MAP_IMAGE_ZOOM4000>
</cmc:GetCustAreaSnapshot>
</ResGetCustAreaSnapshot>
</get:GetCustAreaSnapshotResponseParam>
我应该提取出 MAP_IMAGE_ZOOM 然后使用 base64_decode。解码字符串后,当我回显结果时,我收到以下内容:-
‰PNG IHDR¤¤~LQ5%IDATxœíÝÝvÛ¶FQ¸#ï
这是什么类型的编码??我应该如何将其显示为图像?我试过了 :
file_put_contents('test4000.png', base64_decode($bin));
但显示的图像只是空白。
我还尝试了以下方法,还收到了一张空白图片:
$img = html_entity_decode(base64_decode($bin), ENT_COMPAT,'ISO-8859-1');
Header("Content-Type: image/png");
die($img);
将不胜感激任何帮助。
谢谢