All-in-one-seo's sitemap generation tool broken by BB

Whenever I generate a sitemap with all-in-one-seo I get the following error.

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

Some plugin or theme is adding extra whitespace…

After disabling plugins and themes I have narrowed it down to Beaver Builder (we are using 2.2.23).

Obviously we should upgrade but it’s a new job and they are resistant to updating. Where can I begin looking for the culprit file (I am more comfortable with code than with wordpress).

without seeing the sites xml file honestly it could be anything, also we can only support latest versions.

I updated all beaver builder plugins and the theme on our staging server and re-generated the sitemap with All-In-One-SEO plugin. The problem persists.

The only thing wrong with this xml file is there is a new line at the beginning of the file. You can download the xml here. You’ll have to either take my word that there is a new line at the beginning or download it and open it as both google drive and this forum get rid of that extra empty line in the beginning.

<?xml version="1.0" encoding="UTF-8"?>

<!-- Sitemap dynamically generated by All in One SEO Pack 3.2.3 by Michael Torbert of Semper Fi Web Design on Wed, 14 Aug 2019 12:43:14 UTC -->
<?xml-stylesheet type="text/xsl" href="http://www.example.com/sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>http://www.example.com/addl-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/post-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/page-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/attachment-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/fl-builder-template-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/tribe_events-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/employees-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/category-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/post_tag-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/tribe_events_cat-sitemap.xml</loc>
	</sitemap>
	<sitemap>
		<loc>http://www.example.com/practice-area-sitemap.xml</loc>
	</sitemap>
</sitemapindex>

I just tested the plugin and there is no extra line.

Only thing left to suggest is you have a blank line in a php file somewhere, usually in your theme functions file or more often in the config file.

The give away is every page on your site if you view source will have the blank line, even in the admin pages, because you choose not to share the url I cant check that for you.

Thanks, that’s all I needed to know. Turns out a vendor we work with made a few customizations to function.php and I needed to edit one of the added includes to remove it.

Funnily enough just touching the file was enough to fix it which leads me to believe it was an encoding issue, in case anyone runs into something similar.