XML not generated | Getting "error on line 2 at column 6: XML declaration allowed only at the start of the document"

Created on 31 July 2019, almost 5 years ago
Updated 13 December 2023, 7 months ago

Hi,

I am getting an error when viewing the sitemap.xml:

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

Looking at the issue queue I see that others have had the exact same error/issue but I never saw any resolution.

Looking at the code it does appear that there is a blank line at the top of the error page (see screenshot).

I get the exact same issue using the XML Sitemap module so I know it's not the module's fault, I'm just hoping to find some insight into the cause of the error/issue as I've spent a couple of days already trying to troubleshoot this.

Per some other threads, I've looked at custom modules and themes to see if there were any spaces before the opening <?php ... there were not.

πŸ’¬ Support request
Status

Fixed

Version

3.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States 3CWebDev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States couloir007

    This is still an issue. Does it seem unreasonable that an extraneous space at the beginning or end of a settings.php file should break a module?

  • I agree with statement #16.

    Upon thorough examination of the code, specifically in the .module files, I identified four instances of a potential issue related to blanck space.

    After resolving this issue, my sitemap now generates flawlessly.

  • πŸ‡ΏπŸ‡¦South Africa epicure.club

    If you look at epicure.club/sitemap.xml we also get

    This page contains the following errors:

    error on line 1 at column 8: XML declaration allowed only at the start of the document
    Below is a rendering of the page up to the first error.

    We do not have an empty space at the beginning or the end of settings.php file. Is this a configuration problem?

Production build 0.69.0 2024