XML sitemap troubleshooting
Invalid sitemap XML errors
A sitemap can open normally in a browser or text editor while still containing XML syntax errors, invalid sitemap fields, or a structure that search engines cannot process. Start with the first reported line, repair the generator that produced it, and validate the regenerated document before resubmitting it.
Check the supplied XML first
Paste or upload the sitemap to inspect its root element, namespace, entries, URL locations, dates, frequencies, priorities, and protocol ordering. CorrectSitemap analyzes the content you provide. HTTP status codes, redirects, compression, response headers, robots rules, and live server availability require separate checks against the deployed sitemap URL.
Check sitemap XMLA small valid sitemap
This example contains the required sitemap namespace and one URL entry. The lastmod field is optional, but its value must use a supported W3C date or date-time form when present.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/products/blue-widget</loc>
<lastmod>2026-08-12</lastmod>
</url>
</urlset>
Repair XML syntax before protocol fields
Malformed XML prevents reliable inspection of later entries. Common causes include a missing closing tag, a closing tag with the wrong name, an unquoted attribute, invalid UTF-8 input, and a literal ampersand inside a URL. A query string such as https://example.com/search?color=blue&size=large must serialize the ampersand as & in XML source.
For example, this location breaks XML parsing because the ampersand begins what the XML parser expects to be an entity reference:
<loc>https://example.com/search?color=blue&size=large</loc>
The serialized XML should contain:
<loc>https://example.com/search?color=blue&size=large</loc>
Make this correction in the sitemap generator or template. Hand-editing a generated file may clear one submission while leaving the same defect in the next scheduled build.
Check every URL entry
Each url element needs one non-empty loc child. Use a fully qualified HTTP or HTTPS URL, including its scheme and host. Values such as /products/blue-widget, www.example.com/page, and ftp://example.com/archive fail this structural requirement. The sitemap protocol limits a location value to fewer than 2,048 characters.
A structurally useful entry also keeps the core children in protocol order: loc, then optional lastmod, optional changefreq, and optional priority. Duplicate fields often come from a template loop or from merging two sources. An entry with two loc elements leaves crawlers without one unambiguous location and should be corrected at its source.
After structural validation, review URL selection separately. Search engines generally expect the canonical URLs you want considered for search results. Mixed staging hosts, tracking variants, redirecting URLs, and accidental HTTP/HTTPS duplicates can all be syntactically valid while still making the sitemap less useful.
Use optional metadata carefully
lastmod
A date such as 2026-08-12 is valid. A full date-time may include seconds and a timezone, for example 2026-08-12T14:30:00Z. Calendar values still need to be real: 2026-02-30 and month 13 are invalid. The field should describe the page's last significant modification rather than the time the sitemap job happened to run. Google says it uses lastmod when the values are consistently accurate.
changefreq
The protocol vocabulary is always, hourly, daily, weekly, monthly, yearly, or never. Values such as sometimes and biweekly are invalid. Google currently ignores changefreq, so omitting it is often cleaner than generating an unreliable value.
priority
Priority accepts a decimal from 0.0 through 1.0. It expresses relative importance among URLs on the same site; it does not improve ranking against other sites. Google currently ignores this field as well. Remove it if your generator cannot produce meaningful values.
Why DOCTYPE and entity declarations are rejected
CorrectSitemap stops when it encounters a DOCTYPE or custom entity declaration. Sitemaps do not need those features, and resolving entities adds unnecessary security and resource risks to an anonymous validator. Use ordinary UTF-8 XML and the five predefined XML escapes where needed: &, <, >, ", and '.
Trace the problem back to its generator
Generated sitemaps usually fail at a boundary between application data and XML serialization. A page title or route copied into XML without escaping can introduce a literal ampersand. A database value formatted with a locale-aware date function can produce 08/12/2026 where the sitemap expects an ISO-style date. Joining independently generated fragments can leave a second XML declaration or an extra closing tag in the middle of the file.
Capture a minimal failing input record and add it to the generator's tests. Useful regression cases include URLs with query parameters, non-ASCII path segments, empty optional fields, leap-day dates, and the largest expected batch. A serializer designed for XML is safer than assembling tags through string concatenation because it handles escaping and balanced elements consistently.
Work from the first error outward
- Save the exact bytes produced by the application, CMS, or sitemap job.
- Repair malformed XML first; one broken delimiter can make many later lines appear invalid.
- Confirm the root and namespace, then inspect each reported entry line.
- Regenerate the file and run it through the validator again.
- Deploy the corrected file and request it directly to check HTTP 200 status, final URL, content type, and decompression.
- Resubmit or retest it in the relevant search-engine console after the live response is correct.
Limits and clean results
The public sitemap protocol permits up to 50,000 entries and 50 MB uncompressed. CorrectSitemap applies a tighter 5 MiB request ceiling, along with bounded XML depth, element, attribute, and captured-text limits, so anonymous analysis finishes predictably. A resource-limit result clears partial aggregates and means the submitted document needs to be reduced before this tool can finish its review.
A clean diagnosis confirms that the supplied bytes are structurally plausible within those bounds. Reachability, indexing, canonical selection, authorization for cross-site submission, and the validity of image, video, news, or XHTML extension details remain outside this check.
Protocol references
For the normative element definitions and escaping rules, consult the Sitemaps protocol. Google also documents current behavior for optional fields, canonical URL selection, encoding, and submission in its sitemap construction guide.