Jesse
Jesse

Reputation: 1049

How to validate compliant XML sitemap?

For the following header I get the same two errors on all my sitemaps. It's confusing because, if Google can't read my sitemap, then how can they say that each URL has the same priority? The header counts as line 2, after the XML declaration. Google claims only to have indexed about 2% of the URLs from the maps. Please help.

UPDATE: I think the problem is that I don't know how to validate against a schema. How to do that?

<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/sitemap.xsd">

==Parsing error
We were unable to read your Sitemap. It may contain an entry we are 
unable to recognize. Please validate your Sitemap before resubmitting.

==Notice
All the URLs in your Sitemap have the same priority...

UPDATE: Please be patient, first time validating XML. I don't understand the errors.

Errors in the XML document:
    4:  80  SchemaLocation: schemaLocation value = 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd' must have even number of URI's.
    4:  80  cvc-elt.1: Cannot find the declaration of element 'urlset'.

XML document:
1   <?xml version="1.0" encoding="UTF-8"?>
2   <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4     xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
5     <url>
6       <loc>http://nutrograph.com/1-butter-salted</loc>
7       <changefreq>monthly</changefreq>
8       <priority>0.8</priority>
9     </url>
10    <url>
11      <loc>http://nutrograph.com/2-butter-whipped-with-salt</loc>
12      <changefreq>monthly</changefreq>
13      <priority>0.8</priority>
14    </url>
15  </urlset>

Upvotes: 11

Views: 28325

Answers (6)

Adil Balti
Adil Balti

Reputation: 1

Google Search Console is the best tool to check and validate XML Sitemaps if you have access to it. However, you can check the errors only after submitting the XML Sitemaps. If you want to validate them before submitting them to Google, you have to use other free online tools. There are a few famous tools you can check. All the URLs shared by other members are no longer available except this. https://xmlsitemaps.app/xml-sitemap-validator.html

Upvotes: 0

Larry
Larry

Reputation: 1

Might be worth a check under Google's "Build and submit a sitemap" information located here:

https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap

Under the "XML sitemap" section Google shows a simple example:

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

No complaints from either Google or Bing.

Upvotes: 0

Herry
Herry

Reputation: 1

I was also missing something in this syntax

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xs">

Do you what was missing this syntax?!

Just Letter "d" at the end of url extensions (http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xs)

Resolve my this issue after adding letter "d"

Upvotes: 0

zeonardo
zeonardo

Reputation:

Nottice that the schemaLocation has 2 URi's... (must have even number of URI's)

It should look like this: **

xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"

**

Upvotes: 0

TToni
TToni

Reputation: 9391

Have you validated your XML against the schema given here: http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd

If yes, what was the result?

If not, what is the URL of your sitemap?

If you don't know how to validate the XML against the schema, use http://www.xmlvalidation.com/

Paste the sitemap-XML there, click on "Validate against external XML schema" and paste the schema after clicking the Validate-button.

This will tell you what's wrong with your XML. If you don't know how to interpret the result, please amend your original question accordingly.

Edit: The error was a missing namesapce-URL in the schemaLocation. The first tag has to look like this:

<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">

Upvotes: 8

Mike Edwards
Mike Edwards

Reputation: 442

Strike the above. Looking at Googles site, their sitemap header seems to be a little longer than yours.

It's on this page: https://www.google.com/webmasters/tools/docs/en/protocol.html

<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">

Upvotes: 5

Related Questions