EllisLab text mark
Advanced Search
     
rss feed error “XML or text declaration not at start of entity Location”
Posted: 26 July 2008 11:18 AM
Joined: 2008-02-27
36 posts

I am echoing rss as output from .php code with the header:
header(‘Content-Type: text/xml; charset=utf-8’);

However, I’m getting this error:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://cliixx.com/jon/popular/images/?format=rss
Line Number 1, Column 2: <?xml version=“1.0” encoding=“utf-8” ?>

I think it means there is an extra whitepsace in some file along the chain.

Anyone know where to look?

 
Posted: 26 July 2008 11:31 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-03-12
11 posts

You have a space before “<?xml version=“1.0” encoding=“utf-8” ?>”. Getting rid of it should do the trick.

 
Posted: 26 July 2008 11:46 AM   [ # 2 ]   [ Rating: 0 ]
Joined: 2008-02-27
36 posts

Yes, I think that’s the problem too. But I’ve checked all my files and there are no spaces. I think its a space somewhere in one of the CI core files. But there are so many.

 
Posted: 26 July 2008 11:55 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-03-12
11 posts

Can you post the code for this file?

 
Posted: 30 September 2008 10:07 AM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-10-28
181 posts

I’m running into the same error.  Here’s my controller for testing:

<?php
class Sitemap extends Controller {
    
        
function Sitemap() 
        
{
                parent
::Controller();
        
}
        
        
function index()
        
{
                
echo header("Content-Type: text/xml");
                echo 
'<?xml version="1.0" encoding="UTF-8" ?>';
        
}
}
?> 

With no other spaces being added, its certainly a mystery where its coming from…

Anyone figure this out?

 Signature 

“Clean, Simple & Elegant Web Design”

 
Posted: 05 September 2009 11:29 AM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-10-28
181 posts

I just received a private email asking if I’ve figured this mystery white space issue out. Sadly, the answer is “No”.

I ran some tests (using the same thing as the test Sitemap Controller above (and using both the PHP4 and PHP5 constructs) However, I’m not experiencing the issues using CI 1.7.1 (official release). I’ve been using this release since it was issued without trouble.

I also have my own SVN repository with my own “tweeked” version of CI that I start with at this point.

I haven’t downloaded any of Ellis Labs latest builds.

If the “out of the box” version is still doing it, PM me and I’ll let you download my copy. My “tweeks” are just some extra application files (no core changes) and the pieces for a nice one-user CMS (like fckeditor and the filemanager etc).

If anyone did figure this space issue out, let us know!  I still have a bunch of sites running on the 1.6.* versions that still have errors on the google sitemaps due to the spaces.

 Signature 

“Clean, Simple & Elegant Web Design”

 
Posted: 15 September 2009 11:01 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-11
175 posts

Fixed it - Solution was here: http://ellislab.com/forums/viewthread/74499/#371704

 
Posted: 17 December 2009 03:11 PM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
6 posts

Whoa mate!
Really thanks for this great solution about rss feeds =)

 
Posted: 23 April 2010 10:37 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2010-04-23
1 posts

I still don’t get it sorry I am noob on PHP I just recently started a blog using self hosted Word Press and the feed works on IE but not on FireFox giving me the error:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.farneville.com/feed/rss

Line Number 2, Column 1:<?xml version=“1.0” encoding=“UTF-8”?><!—generator=“WordPress/2.9.2”—>

Now given the solutions here I do not know where to find the php file that has white space.

Lols while writing this I just found the solution it might be worth noting for other people looking for the same. Here it is http://validator.w3.org/feed/docs/error/WPBlankLine.html  LOL

 
Posted: 25 September 2011 02:08 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2011-09-25
1 posts

Thanks mate for posting your reply. It did the trick. There was a space before the ‘?>’.grin