我已經從curl請求中收到這個XML。忽略XML之外的無效char?
<?xml version="1.0" encoding="utf-8"?>
<transaction>
<result>PENDING</result>
<merchanttransid>343434343</merchanttransid>
<transref>23232323</transref>
<errorcode>000</errorcode>
<errormessage/>
<description/>
</transaction>
SMTP Error: Could not connect to SMTP host.
但是,服務器正在回覆SMTP的附加錯誤響應錯誤:無法連接到SMTP主機。現在,當通過simplexml_load_string()解析時。
它拋出一個錯誤:
Entity: line 10: parser error: Extra content at the end of the document (Error Number: 2)
由於中,XML是正確的,只是對響應的問題,有沒有對如何帶額外線的方法嗎?
最好的解決方案是讓服務的創建者修復它。 – CodeZombie 2013-02-25 08:26:51
XML不正確。這也是爲什麼SimpleXML在這裏給出錯誤的原因。如果你想加載它,你需要使用姊妹庫* DOMDocument *並將恢復設置爲true。請參閱[此答案於*「在使用DOMDocument函數處理之前在PHP中修復格式不正確的XML」*](http://stackoverflow.com/a/9281963/367456)。 – hakre 2013-05-10 21:58:43