title: error on line 1 at column 6: XML error on PHP output
body: <p>I have a problem generating valid xml file (for rss feed) with PHP. The problem is: there is no empty character nor a linebreak or tab but the rss reader (in my case Safari) throws an error:</p>
  
  <p>asdf</p>
  
  <p>My PHP code is:</p>
  
  <pre><code>&lt;?php
  header("Content-Type: application/rss+xml");
  
  if(!isset($_GET['searchQuery']) || $_GET['searchQuery'] == "")
  {
      include_once './session_ajax.php';
      include("./include.php"); 
      require_once("./classes/myclass/myclass.class.php");
      $gmap_ajax = new myclass();
  }
  
  $query=sql_query("SELECT item_query, item_date, item_country FROM items WHERE 1 GROUP BY item_query ORDER BY item_id LIMIT 20",1);
  
  $xml = "\n&lt;rss version=\"2.0\"&gt;\n";
  $xml .= "\t&lt;channel&gt;\n\t\t&lt;title&gt;myClass.com RSS Feed&lt;/title&gt;\n\t\t&lt;link&gt;"._siteurl."feed.xml&lt;/link&gt;\n\t\t&lt;description&gt;myClass.com is the largest...&lt;/description&gt;\n\t\t&lt;language&gt;en-en&lt;/language&gt;\n\t\t&lt;pubDate&gt;".date("r")."&lt;/pubDate&gt;\n";
  
  while($row=sql_fetch_array($query,1))
  {
      $date = date("Y-m-d", $row['item_date']);
      $item_query2 = $row['item_query'];
      $item_query = str_replace(" ", "+", $row['item_query']);
      $xml .= "\t\t&lt;item&gt;\n\t\t\t&lt;title&gt;".$item_query2."&lt;/title&gt;\n\t\t\t&lt;link&gt;"._siteurl."/".$item_query."/".$row['item_country']."&lt;/link&gt;\n\t\t\t&lt;description&gt;&lt;![CDATA[Here is some more description]]&gt;&lt;/description&gt;\n\t\t\t&lt;pubDate&gt;".date("r")."&lt;/pubDate&gt;\n\t\t&lt;/item&gt;\n";
  }
  $xml .= "\t&lt;/channel&gt;\n&lt;/rss&gt;";
  echo trim("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;");
  echo $xml;
  ?&gt;
  </code></pre>
  
  <p>In the PHP file there is no space or anything else before the &lt;?php tag and nothing after the ?&gt; tag...</p>
  
  <p>I'm using Adobe CS5 as editor.</p>
  
  <p>In Safari as well as in every online validator I found I get this error:</p>
  
  <pre><code>error on line 1 at column 6: XML declaration allowed only at the start of the document
  </code></pre>
  
  <p>The problem is, I can see the empty space in the source code but the error is located at the "l" of the &lt;?xml tag.</p>
  
  <p>Does anybody have had this problem and has an idea or just a hint to the right direction to solve this problem?</p>
  
  <p>Edit:</p>
  
  <p>I've also tried to open and save it with Noteped++ and Ultraedit32 and then upload it to the server... same problem...</p>