1

My sitemap looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
   <url>
      <loc>http://www.example.com/page1.html</loc> 
   </url>
</urlset>

In the most examples in the internet urlset tag has a xmlns attribute with this value http://www.sitemaps.org/schemas/sitemap/0.9. My question is, what that value comes from?

What exactly should it be?

  1. The path of where my website sitemap file is located?
  2. Literally http://www.sitemaps.org/schemas/sitemap/0.9 ?
Martin AJ
  • 6,261
  • 8
  • 53
  • 111

2 Answers2

1

The Sitemap protocol defines the XML schema which has the namespace http://www.sitemaps.org/schemas/sitemap/0.9.

By using

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

you convey that the urlset element (and its descendants, unless they have a different namespace) should be interpreted according to this Sitemap protocol.

Namespaces help to avoid name collisions. There is no central authority that controls which element names can be used in XML, so any other XML schema may specify an element named urlset, too. Namespaces also allow you to mix elements from different XML schemas, e.g., for extending the Sitemaps protocol.

tl;dr: You have to provide (exactly!) this namespace value, otherwise it wouldn’t be a sitemap as defined by the Sitemap Protocol.

unor
  • 92,415
  • 26
  • 211
  • 360
  • Ok I understood some notes about namespaces and `xmlns` attribute. But still I'm not sure about the value of `xmlns` for my own website. Should it be literally `http://www.sitemaps.org/schemas/sitemap/0.9` ? – Martin AJ Aug 05 '18 at 06:40
  • @MartinAJ: Yes, as the last sentence of my answer says :) If you want to have a sitemap compliant to the Sitemaps Protocol (sitemaps.org), you have to use this namespace. If you use a different namespace, your XML document is not a Sitemaps Protocol sitemap, but something else (depending on the namespace you use). – unor Aug 05 '18 at 13:35
0

I readed many blogs and also read the sitemap protocol at schema.org but the issue was not resolved but after week of reasearching this i found out that

This type of sitemap is for old xhtml sites

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">

And this version is for new html sites as per many cms like wordpress builds i may be wrong

<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
shriekdj
  • 21
  • 6