XML declaration allowed only at the start of the document
When you submit your sitemap sometimes you get this error.
So here is the quick fix to this.
First create whitespace.php in your word press root folder.
Add Below code to that file.
<?php
function ___wejns_wp_whitespace_fix($input) {
$allowed = false;
$found = false;
foreach (headers_list() as $header) {
if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {
$allowed = true;
}
if (preg_match("/^content-type:\\s+/i", $header)) {
$found = true;
}
}
if ($allowed || !$found) {
return preg_replace("/\\A\\s*/m", "", $input);
} else {
return $input;
}
}
ob_start("___wejns_wp_whitespace_fix");
?>
Now add below line to index.php right after <? php tag
include('whitespacefix.php');
Done.
Now you can recheck it should be fixed. For reference check the link