Sitemap XML Error: “XML declaration allowed only at the start of the document

#1053570
  • Resolved Coeur T
    Rank Math free

    Hi Rank Math Support Team,

    I am experiencing an XML parsing error on my sitemap generated by Rank Math. When I access https://hamershopping.com/sitemap_index.xml, I receive the following error:

    pgsql
    复制
    编辑
    error on line 3 at column 6: XML declaration allowed only at the start of the document
    This indicates there is extra whitespace or invisible characters before the XML declaration.

    I have already tried the following troubleshooting steps without success:

    Deactivated all plugins except Rank Math

    Switched to the default WordPress theme (Twenty Twenty-Four)

    Cleared all caches including server, CDN, and browser cache

    Reinstalled Rank Math plugin

    Checked my theme’s functions.php and other custom PHP files for BOM, extra whitespace, or unexpected output

    Verified server does not inject ads or analytics scripts

    Confirmed other XML feeds (like RSS) on my site work fine without errors

    Despite these steps, the sitemap XML error persists.

    Could you please assist me in identifying the cause or provide guidance on further troubleshooting?

    Thank you very much for your support.

    Best regards,

    Vic

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    We apologize for the issue you are facing with the XML parsing error on your sitemap. It sounds like you’ve already taken several thorough troubleshooting steps, which is great.

    The error message you are encountering, "XML declaration allowed only at the start of the document," typically indicates that there is some whitespace or invisible characters before the XML declaration in your sitemap. Here are a few additional steps you can take to resolve this issue:

    1. Check for Whitespace in wp-config.php: Ensure there are no blank lines or spaces before the opening `

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Hello,

    We’ve checked your sitemap, but it seems to be working fine already

    sitemap

    Please clear your website and browser’s cache if you’re still getting the error you have shared.

    Looking forward to helping you.

    Yes, I’ve resolved the issue by recreating the sitemap with the same URL suffix (sitemap_index.xml) using Rank Math. It’s now working properly.

    Thanks again for your support. If you notice anything else that might need improvement, feel free to let me know.

    Hello,

    We’re glad that you have already managed to resolve this issue.

    If you have any other concerns, please don’t hesitate to contact us anytime so we can assist you further.

    Looking forward to helping you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘Sitemap XML Error: “XML declaration allowed only at the start of the document’ is closed to new replies.