title: Creating Google Sitemap from Database
body: <p>I am trying to create a sitemap for google from info supplied from my database, everything works except when I try and use image:image and image:loc I get this error in my xml file:</p>
  
  <p>This page contains the following errors:</p>
  
  <blockquote>
    <p>error on line 8 at column 17: Namespace prefix image on image is not
    defined</p>
  </blockquote>
  
  <p>Below is a rendering of the page up to the first error.</p>
  
  <p>My Code:</p>
  
  <pre><code>//create the xml document
  $xmlDoc = new DOMDocument('1.0');
  
  //create the root element
  $root = $xmlDoc-&gt;appendChild(
            $xmlDoc-&gt;createElement('urlset'));
  $root-&gt;appendChild(
      $xmlDoc-&gt;createAttribute("xmlns"))-&gt;appendChild(
        $xmlDoc-&gt;createTextNode('http://www.sitemaps.org/schemas/sitemap/0.9'));       
  
  foreach($r as $spirit){
  
  $urlSpirit = 'http://urlroot.com' . $spirit['Category'] . '/' .  $spirit['subcategory'] . '/' . $spirit['permName'];
  $imgSpirit = 'http://urlroot.com' . $spirit['picture'];
    //create a url element
    $urlTag = $root-&gt;appendChild(
                $xmlDoc-&gt;createElement("url"));
  
    //create the loc element
    $urlTag-&gt;appendChild(
      $xmlDoc-&gt;createElement("loc", $urlSpirit));
  
    //create the changefreq element
    $urlTag-&gt;appendChild(
      $xmlDoc-&gt;createElement("changefreq", 'weekly'));
  
    //create the priority element
    $urlTag-&gt;appendChild(
      $xmlDoc-&gt;createElement("priority", '1.0'));
  
    //create the lastmod element
    $urlTag-&gt;appendChild(
      $xmlDoc-&gt;createElement("lastmod", $spirit['lastReview']));
  
  
    //create the img element
    $imgTag = $urlTag-&gt;appendChild(
                $xmlDoc-&gt;createElement('image:image'));
  
     $imgTag-&gt;appendChild(
        $xmlDoc-&gt;createElement("image:loc", $imgSpirit));
  }
  
  header("Content-Type: text/plain");
  
  //make the output pretty
  $xmlDoc-&gt;formatOutput = true;
  
  $xmlDoc-&gt;save('test.xml');
  </code></pre>
  
  <p>Any Ideas?</p>