XML Parsing Error: XML or text declaration not at start of entity in php
<p>Hi I am generating a xml file in php  but getting error </p>

<p>XML Parsing Error: XML or text declaration not at start of entity</p>

<p>My code is---</p>

<pre><code>&lt;?php require_once('../../settings.php');
header("Content-type:text/xml");
$dom=new DOMDocument('1.0'); 
$dom-&gt;formatOutput = true;
$id=(int)$_GET['imageid'];
 $query="select * from tbl_image_gallery where imageId='$id' ORDER BY gallId DESC ";
$select=mysql_query($query);
$content = $dom-&gt;appendChild($dom-&gt;createElement('content'));
while($res=mysql_fetch_array($select))
{
    $image = $content-&gt;appendChild($dom-&gt;createElement('image'));
    $small_image_path = $image-&gt;appendChild($dom-&gt;createElement('small_image_path'));
    $small_image_path-&gt;appendChild($dom-&gt;createTextNode("image_gallery/load/images/small/".$res['image'])); 
    $big_image_path = $image-&gt;appendChild($dom-&gt;createElement('big_image_path'));
    $big_image_path-&gt;appendChild($dom-&gt;createTextNode("image_gallery/load/images/big/".$res['image']));
    $description = $image-&gt;appendChild($dom-&gt;createElement('description'));
    $description-&gt;appendChild($dom-&gt;createCDATASection($res['description']));
 }   
echo $test1 = $dom-&gt;saveXML(); 
?&gt;
</code></pre>

<p>After search on google i found that it is problem related to space before </p>

<p>I remove space but not getting expected result.</p>
