我已经从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