Whenever I output an xml file, I always get 9 blank lines of whitespace at the top, anyone know what the problem is? I also get a timestamp at the end which I don't want:
<!-- 0.35s -->
Here's the error:
XML Parsing Error: XML or text declaration not at start of entity
Location: http://example.com/controller/get
Line Number 9, Column 1:<?xml version="1.0" encoding="UTF-8" ?>
I put $this->RequestHandler->setContent('xml','text/xml');
in my controller's beforeFilter()
, and the view looks like this:
<?php echo $xml->serialize($data); ?>
while the layout looks like this:
<?php
header("content-type: text/xml");
echo $this->Xml->header();
echo $content_for_layout;
?>
Any ideas? Thanks.