simplexml_load_string报错:XML declaration allowed only at the start of the document

来源:互联网 发布:linux安装mysql报错 编辑:程序博客网 时间:2024/06/06 00:15

xml数据,data里的为xml数据。注明:带有\r\n的。

{"status_code":200,"msg":true,"data":"\r\n\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><error>0<\/error><message><\/message><\/response>\r\n\r\n"}


在进行转换为字符串simplexml_load_string的时候会报错:XML declaration allowed only at the start of the document


解决办法:

rtrim($data) 加  ltrim($data)。曾经试过直接trim,但是不知为何不管用。


0 0
原创粉丝点击