title: PHP sitemap generator strips tag
body: <p>This is my code to create xml sitemap. But problem is that when it creates xml file it doesn't include <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>. It includes every tag wirteen in my function except that one.</p>
  
  <pre><code>   // this variable will contain the XML sitemap that will be saved in $xmlfile
      $xmlsitemap = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;';
  
      $xmlfile=array('sitemapinternal.xml');
  
      internalSiteMap($xmlsitemap, $xmlfile[0]);
  
  
      //za one vijesti koje su unutar mog sajta /vijesti/kategorija/jSFh8
      function internalSitemap($xmlsitemap, $xmlfile)
      {
          // Define and perform the SQL SELECT query
          $sql = "SELECT * FROM table";
          $result = $mysqli-&gt;query($sql);
  
          // If the SQL query is succesfully performed ($result not false)
          if($result !== false) 
          {
              // Parse the result set, and add the URL in the XML structure
              while($red=$result-&gt;fetch_assoc())
              {
                  $xmlsitemap .= 
                  '&lt;url&gt;
                  &lt;loc&gt;http://www.example.com&lt;/loc&gt; 
                  &lt;priority&gt;0.5&lt;/priority&gt;
                  &lt;changefreq&gt;yearly&lt;/changefreq&gt;
                  &lt;lastmod&gt;'.date('Y-m-d', strtotime($red['datum'])).'&lt;/lastmod&gt;
                  &lt;/url&gt;';
              }
          }
  
          $xmlsitemap .= '&lt;/urlset&gt;';
          file_put_contents($xmlfile, $xmlsitemap);          // saves the sitemap on server
      }
  </code></pre>