title: laravel site map and casting to xml
body: <p>I have written a sitemap with the help of <a href="https://laravel-news.com/laravel-sitemap" rel="nofollow noreferrer">https://laravel-news.com/laravel-sitemap</a></p>
  
  <p>here is my index : </p>
  
  <pre><code>public function siteMap(  )
  {
      $news=News::orderBy('time','desc')-&gt;where('time','&lt;',time())-&gt;where('showview',1)-&gt;first();
      $categories = Cat::orderBy('id' , 'desc')-&gt;first();
      $games = Game::orderBy('id' , 'desc')-&gt;first();
      $genres = Genre::orderBy('id' , 'desc')-&gt;first();
      $movies = Movie::orderBy('id' , 'desc')-&gt;first();
      $platforms = Platform::orderBy('id' , 'desc')-&gt;first();
  
      return response()-&gt;view('siteMap.siteMap', [
  
          'news'          =&gt;  $news,
          'categories'    =&gt;  $categories,
          'games'         =&gt;  $games,
          'genres'        =&gt;  $genres,
          'movies'        =&gt;  $movies,
          'platforms'     =&gt;  $platforms
  
      ])-&gt;header('Content-Type', 'text/xml');
      }
  </code></pre>
  
  <p>and my blade  : </p>
  
  <pre><code>&lt;?php
  
  echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'; ?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>{{-- site map for posts --}}
  &lt;sitemap&gt;
      &lt;loc&gt; //url /{{ $news-&gt;id }}/{{ $news-&gt;title }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c',$news-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  
  {{-- sitemap for categories --}}
  &lt;sitemap&gt;
      &lt;loc&gt;//url/{{ $categories-&gt;id }}/{{ $categories-&gt;name }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c',  $categories-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  
  {{-- sitemap for games profile --}}
  &lt;sitemap&gt;
      &lt;loc&gt;//url/profiles/games/{{ $games-&gt;id }}/{{ $games-&gt;name }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c', (integer) $games-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  
  {{-- sitemap for genres profile --}}
  &lt;sitemap&gt;
      &lt;loc&gt;//url/{{ $genres-&gt;id }}/{{ $genres-&gt;name }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c',  $genres-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  
  {{-- sitemap for movie profile --}}
  &lt;sitemap&gt;
      &lt;loc&gt;//url/{{ $movies-&gt;id }}/{{ $movies-&gt;name }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c',  (integer) $movies-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  
  {{-- sitemap for platforms profile --}}
  &lt;sitemap&gt;
      &lt;loc&gt;//url/{{ $platforms-&gt;id }}/{{ $platforms-&gt;name }}&lt;/loc&gt;
      &lt;lastmod&gt;{{ date('c', (integer) $platforms-&gt;time) }}&lt;/lastmod&gt;
  &lt;/sitemap&gt;
  </code></pre>
  
  <p></p>
  
  <p>after uploading on host and using google webmaster i get below error : </p>
  
  <p>Your Sitemap appears to be an HTML page. Please use a supported sitemap format instead. </p>
  
  <p>thanks for your help !</p>