Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Sitemap XML invalid or wrong namespace: how to find and fix it

SEO-103Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

An XML sitemap is a file that lists the URLs you want search engines to crawl. It follows a strict format. If the format is broken, a crawler cannot read it. Two faults are common: malformed XML (an unclosed tag, an unescaped &, text before the first tag) and a wrong or missing namespace (the xmlns value on the root element).

A valid minimal sitemaphtml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/</loc>
    <lastmod>2025-01-15</lastmod>
  </url>
</urlset>

Why it costs you leads or sales

If a search engine cannot parse your sitemap, it falls back on following links. New landing pages, product pages and offers may be found later, or missed if they are poorly linked. Pages that are not indexed cannot bring in organic leads or sales. The effect is usually gradual, which is why it goes unnoticed. Your site still loads and your forms still work.

How a broken sitemap delays organic leads
  1. New page publishedLanding page goes live
  2. Sitemap readInvalid XML or wrong namespace
  3. Page discoveredOnly through links, if at all
  4. Indexed and rankedDelayed or missing
  5. Organic leadForm never sees the visitor

The break sits at the sitemap read step; everything after it slows down or is lost.

How to check if your site has it

Check your sitemap for XML and namespace errors
  1. Open the sitemap in a browser

    Go to /sitemap.xml (or /sitemap_index.xml, /wp-sitemap.xml). You should see a tree of URLs or a note that the file has no style information. A blank page, an HTML page or a visible error message is a red flag.

  2. View the page source

    Right-click, then View page source. The first characters must be <?xml. Any blank line, warning text or HTML before it can break parsing.

  3. Check the root tag

    Confirm it reads <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> or <sitemapindex ...> with the same namespace. Look for typos, a missing xmlns, or https in the namespace.

  4. Look at Search Console

    In Google Search Console open Indexing, then Sitemaps. Statuses such as 'Couldn't fetch' or 'Sitemap could not be read', or an error about parsing, point to this problem. Check Bing Webmaster Tools Sitemaps too.

  5. Validate the file

    Run the file through an XML validator or a sitemap validator. From a terminal, xmllint --noout sitemap.xml reports the line of any syntax error.

Fetch and check the sitemap from a terminalbash
curl -s https://www.example.com/sitemap.xml -o sitemap.xml
head -c 200 sitemap.xml
xmllint --noout sitemap.xml && echo "XML is well formed"
grep -o 'xmlns="[^"]*"' sitemap.xml | head -1
Common causes and what you will see
CauseWhat you seeTypical source
Text or warnings before <?xmlParse error on line 1PHP notice, extra blank line in a theme file
Unescaped & in a URLParse error mid-fileHand-built or custom sitemap
Wrong or missing xmlnsNamespace error or zero URLs readHand-edited file, old generator
HTML returned instead of XMLPage looks like your siteCaching, security plugin or redirect to a page
Wrong content typeDownloads or shows as textServer config

How to fix it

Where possible, let your platform generate the sitemap instead of editing it by hand. Then remove whatever is polluting the output.

Fix by platform
  1. Find which plugin builds the sitemap

    Yoast SEO, Rank Math, All in One SEO and WordPress core (/wp-sitemap.xml) can all do it. Use one only.

  2. Clear stray output

    Turn on WP_DEBUG_LOG (not display) so PHP notices go to a log file instead of the page. Check functions.php and mu-plugins for closing ?> tags followed by blank lines.

  3. Test with plugins off

    Disable caching, minify and security plugins one by one and reload the sitemap. Some inject comments or HTML. Then purge caches.

  4. Refresh permalinks

    In Settings, then Permalinks, click Save Changes to rebuild rewrite rules if the sitemap URL returns a page instead of XML.

Sitemap index with the correct namespacehtml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://www.example.com/sitemap-pages.xml</loc>
  </sitemap>
</sitemapindex>
Broken versus valid sitemap

Invalid

  • Warning text before `<?xml`
  • `xmlns` missing or misspelled
  • `&` unescaped in a URL
  • Returns an HTML page

Valid

  • File starts with `<?xml`
  • Namespace is the sitemaps.org 0.9 address
  • Special characters escaped
  • Served as XML and read by Search Console

How to confirm it's fixed

Confirmation checklist
  • The sitemap URL loads as XML with no text before <?xml
  • xmllint --noout or an XML validator reports no errors
  • The root tag has xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  • The response header is application/xml or text/xml with status 200
  • Search Console shows status Success after you resubmit it
  • Bing Webmaster Tools reads the file with no errors

How to prevent it happening again

Prevention habits
  • Generate the sitemap with your platform or a maintained plugin, not by hand
  • Run only one sitemap generator at a time
  • Re-validate after theme, plugin, caching or CDN changes
  • Keep PHP and server errors out of page output in production
  • Check the Sitemaps report in Search Console after each major release
  • Turn on email notifications in Search Console and Bing Webmaster Tools
Example: how an invalid sitemap goes unnoticed
  1. Day 1

    A plugin update prints a PHP notice at the top of the sitemap.

  2. Day 3

    Search Console marks the sitemap as unreadable. Nobody opens the report.

  3. Week 3

    New landing pages are still not indexed.

  4. Week 4

    Notice removed, sitemap resubmitted and read successfully.

How FunnelGuard handles this

FunnelGuard does not check sitemap XML or namespaces yet. It is a possible future check, not a current feature. FunnelGuard is a synthetic monitoring service: a robot visitor runs your real customer journeys, such as lead forms, checkouts and booking buttons, and checks each step, the tracking hits and whether test leads arrive.

That covers what happens after a visitor lands on your site, so it will not tell you that a sitemap is unreadable. To watch for this, use the Sitemaps report and email notifications in Google Search Console and Bing Webmaster Tools, and run a validator or xmllint after releases. A free read-only website audit from FunnelGuard is also available, but do not rely on it for sitemap validity.

Questions people ask

Why does Google Search Console say my sitemap could not be read?

The file usually has malformed XML, a wrong namespace, or returns HTML instead of XML. Open the sitemap URL, view the source, and check that it starts with <?xml and a correct urlset tag. Then open the error details in Search Console for the exact line.

What is the correct namespace for an XML sitemap?

The namespace is http://www.sitemaps.org/schemas/sitemap/0.9. It goes in the xmlns attribute of the root <urlset> or <sitemapindex> tag. Use http, not https, in that value.

How do I validate my sitemap XML?

Use an online XML or sitemap validator, or run xmllint --noout sitemap.xml in a terminal. Also resubmit the sitemap in Google Search Console and check that its status shows Success.

Why does my WordPress sitemap show a blank page or an error?

Often a plugin conflict, a PHP notice or a caching layer is altering the output. Check that only one plugin makes the sitemap, hide PHP errors from page output, purge caches, and resave Settings, then Permalinks.

Do I need to escape ampersands in sitemap URLs?

Yes. In XML, write & as &amp; inside <loc>. An unescaped ampersand makes the file malformed and can cause the whole sitemap to fail to parse.

Can I edit the sitemap on Shopify, Wix or Squarespace?

No. These platforms generate the sitemap automatically and it cannot be edited. If it looks invalid, check for redirects, apps or domain settings that alter it, and resubmit it in Search Console.

Does FunnelGuard check if my sitemap is valid?

Not yet. Sitemap validation is a possible future check. For now, use Search Console, Bing Webmaster Tools and an XML validator to watch it.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.