XML parsing error: xml processing directive is not at the beginning of the entity
Location: http://.../public/xml/get
Row: 2, Column: 1:
^
After careful inspection, I found that the first line is empty. After searching for a long time, I couldn't find where zend's view outputs a blank line, including initializing a new View, but I still haven't found the reason, but the first line of the website homepage is not empty.
There are similar examples on the Internet, but their solution is to pay attention to controlling the output, but I don’t know how View controls the output. After working for a long time without success, I almost collapsed. I decided to give up this method and write the xml file to the server first and then call it. Obviously this will reduce the performance of the website.
After changing the method, I tried to find a solution. I looked for information related to PHP memory and tried to add ob_end_clean(); before the output, as follows:
$xmlfile = $doc ->saveXML();
//$doc->save("data.xml");
ob_end_clean();
$this->view->xml = $xmlfile;
Just write one sentence at the top of the view:
=$this->xml; ?>
Then adjust it again, haha, it’s successful.