2015-02-18, 11:35 PM
First of all, sorry for my english.
I'm developing the next release of my plugin MySEO and when I try to make a sitemap with a single php file in root, with the header() functions and the code correctly, I can see this error:
I'm developing the next release of my plugin MySEO and when I try to make a sitemap with a single php file in root, with the header() functions and the code correctly, I can see this error:
Quote:This page contains the following errors:
error on line 1 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
The error is showed when I write the code to include global.php file in the file.
This require_once add three whitespaces in top of content.
How can i solve it?
Example of the code:
Results in:
With three whitespaces in top of content.
Thanks.
This require_once add three whitespaces in top of content.
How can i solve it?
Example of the code:
define("IN_MYBB", 1);
require "./global.php";
global $mybb;
header("Content-Type: application/xml; charset=utf-8");
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
$sitemap .= '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$sitemap .= '<url>';
$sitemap .= '<loc>'.$mybb->settings['bburl'].'</loc>';
$sitemap .= '<changefreq>blablabla</changefreq>';
$sitemap .= '</url>';
$sitemap .= '</urlset>';
echo $sitemap
Results in:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<url>
<loc>http://localhost/dev</loc>
<changefreq>blablabla</changefreq>
</url>
</urlset>
With three whitespaces in top of content.
Thanks.