XML sitemap
What goes wrong in XML sitemap
The 17 errors this corpus records against XML sitemap documents, keyed by the message your parser printed. Nothing here is written for this page — each error declares the formats it bites, and this is that declaration read the other way round.
Start with the message you were given
Every entry below states the message our validator emits, verbatim, and a test asserts it still does. If you are holding a broken document rather than a question, Sitemap validator will tell you which of these you have.Parse errors · 17
These stop the document being read at all. Nothing downstream sees a file with one of them, because it is not XML.
- Opening and ending tag mismatch
Opening and ending tag mismatch: item line 2 and channel (line 4)An element was closed out of order: the parser met an end tag for an ancestor while a child was still open, so the tree cannot be built at all. - Premature end of data in tag
Premature end of data in tag urlset line 1 (line 2)The document ended while one or more elements were still open — almost always truncation, not an authoring mistake. - Extra content at the end of the document
Extra content at the end of the document (line 2)Something follows the root element — a second root, a stray closing tag, or a fragment that was never a whole document. - Unescaped ampersand (EntityRef: expecting ';')
EntityRef: expecting ';' (line 2)A bare & appeared in content. XML reads it as the start of an entity reference and expects a name and a semicolon. - Start tag expected
Start tag expected, '<' not found (line 1)What arrived is not XML — an HTML error page, a JSON body, or plain text served under an XML content type. The parser found no opening tag. - XML declaration allowed only at the start of the document
XML declaration allowed only at the start of the document (line 2)Whitespace precedes the XML declaration. A single blank line, or one space, before it is enough to make the document not well-formed. - Unquoted attribute value (AttValue expected)
AttValue: " or ' expected (line 1)An attribute value is not quoted. XML requires quotes around every value, including numbers — unlike HTML, which accepts bare values happily. - Attribute redefined
Attribute href redefined (line 1)The same attribute name appears twice on one element, which XML forbids outright. HTML silently keeps the first; XML refuses the document. - Attributes construct error (unterminated quote)
attributes construct error (line 1)An attribute value was opened with a quote that is never closed, so the parser runs past the end of the tag looking for the matching one. - Document is empty
Document is empty (line 1)Nothing arrived at all. Almost always a transport problem — a 204, a dropped connection, or a fetch that succeeded against the wrong URL. - Unsupported encoding
Unsupported encoding: UTF-9 (line 1)The declaration names an encoding the parser cannot decode — a typo, a vendor-specific label, or a charset the build of libxml2 was not compiled with. - Unescaped '<' in an attribute value
Unescaped '<' not allowed in attributes values (line 2)A literal < inside an attribute value. XML forbids it there because the parser cannot tell it from the start of a tag, so it must be written <. - Blank needed here
Blank needed here (line 1)Two parts of the XML declaration ran together with no space between them. Terse enough to be baffling, and it always means the same thing. - Malformed declaration expecting version
Malformed declaration expecting version (line 1)The document opens with <?xml but no version attribute. Version is the one part of the declaration that is not optional, and it must come first. - Processing instruction not terminated
ParsePI: PI target never end ... (line 2)A processing instruction was opened with <? and never closed with ?>. Everything after it is consumed as instruction data until the file runs out. - Error parsing attribute name
error parsing attribute name (line 2)A start tag was never closed with >, so the parser kept reading and found the next element's markup where an attribute name should have been. - CharRef: invalid decimal value
CharRef: invalid decimal value (line 2)A numeric character reference was opened with &# and never closed with a semicolon, so the parser read past the digits into text that is not a number.
Where these land
The elements of a XML sitemap document, each with the rules it has to follow and a broken and a fixed example that were run.
- <urlset>The root element of every sitemap. Its namespace declaration is what makes the document a sitemap rather than a list of URLs.
- <url>One entry in a sitemap: a required <loc> plus the optional metadata a crawler may or may not use.
- <loc>The URL itself — the only required child of <url>, and the element where ampersands in query strings go wrong.
- <lastmod>When the page last changed. The one piece of sitemap metadata search engines still act on — and only if you keep it honest.
- <changefreq>A hint at how often a page changes, drawn from a fixed list of eight values — and ignored by every major search engine.
- <priority>A number from 0.0 to 1.0 expressing a URL's importance relative to others on the same site — also ignored, and routinely misunderstood.
- <xhtml:link>An hreflang alternate for a URL, declared in the XHTML namespace — the only correct way to express language variants in a sitemap.
- <image:image>An image carried by a page, declared inside its <url> — the extension that survived while its siblings were cut back.
- <news:news>The Google News extension: a publication block and a publication date, on URLs from the last two days only.
- <video:video>A video on a page: thumbnail, title, description and a location, with the strictest required-child list of any sitemap extension.
Back to XML sitemap — root element, namespaces, constraints and a worked example.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.