-
- 15 Posts
Hi, I've been trying to generate a sitemap through the google site map plugin. The plugin seems to have worked fine - viewing the page source brings up all the xml, but there's a blank line at the start of the page which is bringing up the following error:
error on line 2 at column 6: XML declaration allowed only at the start of the document
There's a blank line at the start of every page of the site, not just this page too.
I've noticed some people have added the rich text option which brought up p tags either side of the xml tag, but i've fixed this and still getting this error.
I've checked the database to see if there is any spaces at the start of the content and there isn't.
Hope someone can help, thanks in advance!
-
- 41 Posts
Hi, did you use some template for resource in sitemap snippet use?
-
- 15 Posts
No, I set it to the empty one. No idea why it's adding the blank line
-
- 571 Posts
Is 'Settings / Content type' set to XML?
-
- 15 Posts
Yeah it is, I'm using version 2.5.4 too, if that helps at all
-
- 571 Posts
Are you happy to tell me the url of the site so people can view-source?
-
- 8 Posts
Any update on this? I'm having the same issue and it's breaking 2 of my xml file outputs.
-
- 571 Posts
Is it possible that you or the hosting company have a php.ini file in place somewhere with the following instruction in it?
See this conversation
http://stackoverflow.com/questions/14825996/php-spits-a-new-line-before-any-output
This could be calling in a php file that has a line break at the end which places a space at the top of all you pages.
This would break any xml pages as they will not allow the declaration to be on any line other than line one. HTML is a bit kinder and allows the page to display, but puts the space in to the top of the page.
-
- 15 Posts
Sorry Andy, was busy trying to get the site live. Had to manually do the sitemap.xml for the time being in the root of the project and just add to it as and when any pages get created.
Not really able to send a url unfortunately, not up to me i'm afraid.
I checked the php.ini file and it did have auto-prepend-file just as auto-prepend-file= I tried commenting it out with a semi-colon, but it didn't seem to make a difference after restarting php and apache and it still didn't work.
Thanks for all the suggestions though
-
- 571 Posts
It might be worth checking Manage > Reports > System Info in the MODX Manager. This will return info about your php environment. You may still find that
auto-prepend-file is enabled elsewhere.
Looking at this article
https://www.electrictoolbox.com/php-automatically-append-prepend/ it seems that the
auto-prepend-file option can be set in your
PHP config,
virtualhost settings or
.htaccess file.