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,但是不知为何不管用。
{"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,但是不知为何不管用。
相关文章推荐
- error on line 1 at column 6: XML declaration allowed only at the start of the document
- Php输出Xml报错:XML declaration allowed only at the start of the document
- XML declaration allowed only at the start of the document 问题解决方法
- php 输出xml错误不能解析,XML declaration allowed only at the start of the document
- asp输出xml格式文件时的一个诡异错误及解决方法:XML declaration allowed only at the start of the document
- 【XML码农】【Error】The XML declaration may only appear at the very beginning of the document.
- python读取xml文件报错xml.parsers.expat.ExpatError: XML or text declaration not at start of entity
- Android编译出现XML or text declaration not at start of entity
- XML or text declaration not at start of entity
- XML文件要有根标签(Extra content at the end of the document in file 错误)
- Error:(6) Error parsing XML: XML or text declaration not at start of entity
- PHP - XML parse error: Extra content at the end of the document
- XML or text declaration not at start of entity异常的原因
- nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
- Qt5:"Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document."错误
- org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException: The content of elements must consi
- Unexpected XML declaration. The XML declaration must be the first node in the document and no white
- XML document structures must start and end within the same entity
- Question 12: In C++, which of the following is the best declaration for an overloaded operator[] to allow read-only access (and
- 解决eclipse启动tomcat报错:Could not load the Tomcat server configuration at \Servers\Tomcat v6.0 Server at localhost-config. The Servers project is closed.