我正在使用以下代码从电子邮件下载和阅读XML文件:
<?php
require_once("attachmentread.class.php");
$host="{imap.gmail.com:993/imap/ssl}INBOX"; // pop3host
$login="axxxxxxxx@gmail.com"; //pop3 login
$password="whxxxxxxx"; //pop3 password
$savedirpath="" ; // attachement will save in same directory where scripts run othrwise give abs path
$jk=new readattachment(); // Creating instance of class####
$jk->getdata($host,$login,$password,$savedirpath); // calling member function
$xml=simplexml_load_file("/data/www/Message14.xml");
$message=$xml->TEMPLATE;
$mobile= $xml->MESSAGES->MESSAGE->RECIPIENT_NUM;
$mobile1=str_replace("050", "97150", $mobile);
?>
我原来的Message14.xml看起来像这样
<?xml version="1.0" ?>
<DOCUMENT><VERSION>2.0</VERSION><INVOICE_NUM>30</INVOICE_NUM><PIN>14567894</PIN><MESSAGE_TYPE>INSTANT_SEND</MESSAGE_TYPE><COUNTRY_CODE>971</COUNTRY_CODE><TEMPLATE> Hi xxxxxx
</TEMPLATE><DATABASEINFO><DATABASE_NAME>Sys2000</DATABASE_NAME><CLINIC_ID>1</CLINIC_ID></DATABASEINFO><MESSAGES><MESSAGE><SEND_DATE>2013-07-02</SEND_DATE><ENTITY_ID>0</ENTITY_ID><RECIPIENT_NUM>xxxxxxxxx</RECIPIENT_NUM><MESSAGE_PARAMS/></MESSAGE></MESSAGES><CSUM>dcb4855eccf730e3668a386acaaf7d60</CSUM></DOCUMENT>
但现在它包含3D,看起来像这样
?xml version=3D3D"1.0" ?>
<DOCUMENT><VERSION>2.0</VERSION><INVOICE_NUM>30</INVOICE_NUM><PIN>1456789=
=3D
4</PIN><MESSAGE_TYPE>INSTANT_SEND</MESSAGE_TYPE><COUNTRY_CODE>971</COUNTR=
=3D
Y_CODE><TEMPLATE> Hi xxxxxxxxx
</TEMPLATE><DATABASEINFO><DATABASE_NAME>Sys2000</DATABASE_NAME><CLINIC_ID=
=3D
>1</CLINIC_ID></DATABASEINFO><MESSAGES><MESSAGE><SEND_DATE>2013-07-02</SE=
=3D
ND_DATE><ENTITY_ID>0</ENTITY_ID><RECIPIENT_NUM>0xxxxxxxxx</RECIPIENT_NUM>=
=3D
<MESSAGE_PARAMS/></MESSAGE></MESSAGES><CSUM>dcb4855eccf730e3668a386acaaf7=
=3D
d60</CSUM></DOCUMENT>
任何人都可以指导我如何下载原始文件而不包含3d。谢谢
答案 0 :(得分:1)
“3D”指的是等号的字符代码。在XML代码中包含它表示发生了双重编码或其他编码问题。您可以使用PHP的 quoted_printable_decode 函数来解决问题。 PHP's manual here
您可以尝试:file_put_contents("/data/www/Message14.xml", quoted_printable_decode(file_get_contents("/data/www/Message14.xml")));
在使用simplexml_load_file函数之前放置它。