title: How to avoid namespace in child nodes using FOR XML PATH?
body: <p>I want to create a sitemap xml file (including images) directly from the database without another process (like transformation or another trick).</p>
  
  <p>My query is:</p>
  
  <pre><code>;WITH XMLNAMESPACES(
      DEFAULT 'http://www.sitemaps.org/schemas/sitemap/0.9',
      'http://www.google.com/schemas/sitemap-image/1.1' as  [image] )  
  SELECT  
      (SELECT             
          'mysite'    as [loc],
          (select   
              'anotherloc'
              as [image:loc]
          for XML path('image:image'), type
          )
      for xml path('url'), type
  )
  for xml path('urlset'), type
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>&lt;urlset xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
    &lt;url xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
      &lt;loc&gt;mysite&lt;/loc&gt;
      &lt;image:image xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
        &lt;image:loc&gt;anotherloc&lt;/image:loc&gt;
      &lt;/image:image&gt;
    &lt;/url&gt;
  &lt;/urlset&gt;
  </code></pre>
  
  <p>But I need this output, without repeated namespace declaration:</p>
  
  <pre><code>&lt;urlset xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
    &lt;url&gt;
      &lt;loc&gt;mysite&lt;/loc&gt;
      &lt;image:image&gt;
        &lt;image:loc&gt;anotherloc&lt;/image:loc&gt;
      &lt;/image:image&gt;
    &lt;/url&gt;
  &lt;/urlset&gt;
  </code></pre>