您的位置:首页 > 编程语言 > PHP开发

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

2017-05-11 16:20 591 查看
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,但是不知为何不管用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐