Hi,
The error ‘XML declaration allowed only at the start of the document’ is typically caused when another file, plugin, or theme adds additional code or white space to the beginning of the sitemap file.
In order to resolve this, I would first recommend clearing your site’s caching.
If after clearing your site’s cache you are still experiencing the error on the sitemap, I would then next recommend checking your theme’s functions.php file for an empty line at the end of the file, as well as your wp-config.php file for any additional spaces at the beginning of the file.
If you cannot find any empty lines at the end of your theme’s functions.php file or blank lines or spaces at the start of the wp-config.php, I would next recommend running a conflict check to identify whether another plugin or them is outputting the additional code in the sitemap file. The fastest way to do this is to deactivate all non-Rank Math plugins and switch to a standard theme like TwentyTwenty.
Test this on your development or staging site, if you have one. If not, I recommend using the Health Check & Troubleshooting plugin. This plugin allows you to run a conflict check without affecting normal visitors to your site.
Hope this helps!