A common error if you have a blog or online store created with WordPress and on which you use the SEO, Rank Math or Yoast SEO plugins, is: "error on line 2 at column 6: XML declaration allowed only at the start of the document". This error occurs when you open the sitemap XML file (sitemap_index.xml) and can affect search engine optimization quite a bit (SEO).
I looked for various solutions to fix it and even found useless scripts shown on YouTube.
If you have a website created with WordPress and you encountered this error, most of the time it is about one or more blank lines of code at the beginning or end of the files wp-config.php or functions.php (active blog theme file).
The solution is very simple. Delete these two lines of code, then save the edited file. Lines 113 and 114, in the example above.
After you make this change, there's a good chance that the sitemap error will go away and everything will be back to normal.
Related: Links do not have a discernible name. Lighthouse Fix
If the error still occurs, you can disable one by one of the enabled plugins or change the blog theme to identify where the file that is causing this problem is.