Sitemap Looks Garbled in the Browser But Validates Fine Everywhere Else: An xmlns:xhtml Namespace Collision Explained

TL;DR — A bilingual sitemap using the standard xmlns:xhtml namespace (for <xhtml:link rel="alternate" hreflang="..."> entries) rendered as garbled, malformed-looking markup when opened directly in a browser — while Search Console and every XML validator confirmed the file was perfectly valid. It's a client-side rendering artifact, not real corruption, and it has no effect on crawlers or SEO.
Table of Contents
Diagnostic
curl -s https://your-site.com/sitemap.xml | xmllint --noout -
# no output -> valid XML
curl -sI https://your-site.com/sitemap.xml | grep -i content-type
# Content-Type: application/xml; charset=utf-8If the raw response validates and has the right Content-Type, the "corruption" only exists in how the browser chose to render it, not in the file itself.
Root cause
Browsers have a built-in fallback renderer that pretty-prints XML as if it were HTML when it can't apply a real XML stylesheet. When a sitemap declares both its own <xhtml:link> elements and the xhtml namespace, that fallback renderer can get confused between the document's own namespaced elements and real HTML <link> elements, and render the whole thing as malformed HTML instead of clean XML.
Fix
This is cosmetic-only — crawlers parse XML directly, they don't render it visually, so it doesn't affect indexing or SEO in any way. Leave it alone unless prettier manual browser viewing specifically matters to someone; in that case, the real fix is an XSL stylesheet reference, not touching the sitemap's own markup.
Lessons learned
- Always validate the raw server response before assuming a rendering glitch is a real bug — a five-second curl + xmllint check settles it.
- Compare against a sibling sitemap that doesn't use the xhtml namespace, if one exists, to confirm the pattern rather than guessing.




Comments