Welcome Guest, Not a member yet? Register   Sign In
rss feed error "XML or text declaration not at start of entity Location"
#1

[eluser]jonnyjon[/eluser]
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?
#2

[eluser]Philip Ramirez[/eluser]
You have a space before "<?xml version="1.0" encoding="utf-8" ?>". Getting rid of it should do the trick.
#3

[eluser]jonnyjon[/eluser]
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.
#4

[eluser]Philip Ramirez[/eluser]
Can you post the code for this file?
#5

[eluser]SitesByJoe[/eluser]
I'm running into the same error. Here's my controller for testing:

Code:
<?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?
#6

[eluser]SitesByJoe[/eluser]
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.
#7

[eluser]mattpointblank[/eluser]
Fixed it - Solution was here: http://ellislab.com/forums/viewthread/74499/#371704
#8

[eluser]boltoncole[/eluser]
Whoa mate!
Really thanks for this great solution about rss feeds =)
#9

[eluser]Unknown[/eluser]
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/...kLine.html :lol:




Theme © iAndrew 2016 - Forum software by © MyBB