error on line 2 at column 6: XML declaration allowed only at the start of the do

#916034
  • Resolved Ett Gai
    Rank Math free

    This page contains the following errors:
    error on line 2 at column 6: XML declaration allowed only at the start of the document
    Below is a rendering of the page up to the first error.

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    This error means that there is some extra content or whitespace before the XML declaration in your sitemap. This can make your sitemap invalid and unreadable by search engines.

    The most common reason for this error is a whitespace in your theme code, such as a blank line or space in your wp-config.php file or your theme’s functions.php file. This can happen when you edit these files manually or use a plugin or theme that modifies them.

    To fix this error, you need to find and remove the whitespace from your theme code.

    You can follow this guide to troubleshoot and resolve this issue: https://rankmath.com/kb/fix-sitemap-issues/#xml-text-declaration

    Looking forward to helping you.

    Ett Gai
    Rank Math free

    I made sure there are no blank lines or spaces in the wp-config.php and functions.php files

    Hello,

    There are two potential reasons for this.

    1. You have a space before the opening PHP tag in one of the files that is being loaded into the website. Most of the time, that issue happens in the wp-config.php or functions.php file.

    2. You have a closing PHP tag on a file that doesn’t need it so the headers are sent twice. This is much difficult to track because it could be happening on any PHP file on the installation and that includes the theme and plugins installed.

    The easiest way to get around this immediately is by applying the following patch: https://wejn.org/stuff/wejnswpwhitespacefix.php.html

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘error on line 2 at column 6: XML declaration allowed only at the start of the do’ is closed to new replies.