WordPress XML Parsing Error
No sooner did I write the post about troubleshooting I came across a WordPress error that took way more time to solve than I expected.
One thing I know as a programmer is that every single character in a file is critical. I can not even guess how many times a simple question mark or apostrophe has caused me to lose hours of time trying to find. And here is a perfect case of troubleshooting a WordPress error that was so simple, yet so hard. The error was an XML Parsing Error.
I have a new site (NonPartyPolitics.com) that I have been working on and I realized the RSS Feed was not displaying, the following error was popping up.

Looks pretty obvious, there was an error at line 2, column 1. Step one was to see what was happening, so the first thing I did was look at the source of this page. Nothing jumped out at me, so I loaded a working WordPress site, pulled up the RSS feed and looked at the source, I placed the 2 files side by side and there it was. On the feed with the error there were 2 blank lines before the code. Interesting. I then pulled up the home page for both sites and the same thing, there were 2 extra blank lines on the home page source. This told me that the problem was probably not in the RSS code, but it could still be in the code somewhere.
The next logical step was thinking of what I changed last. I really had not done much outside the template except installing a couple plugins. So, I turned off all plugins. Now the hard part was having a little patience. I could see that on the home page the 2 blank lines were now gone, but I had to edit a post and wait for the feed to catch up.
Sure enough that was it, 2 blank lines were gone in the feed. Now, which plugin?
Here is a little logic for you, if I have 2 blank lines, and I know a plugin is causing it, all I need to know is which plugin is issuing 2 extra carriage returns. The key to this is to know that I was not looking for the plugin actually writing the blank lines, I was looking for a plugin with 2 extra carriage returns. And I found the culprit.
I am not going to call it by name because the plugin worked fined on other sites and it did not download from the original like this. Either I did something to cause this problem, or it was just a fluke.
Here is the plugin before I fixed it…..

and here is the plugin after the fix…

So there we go, a real WordPress troubleshooting case solved. All of that because of 2 extra carriage returns.
Make sure when you are working with code you are aware of every character and every space!
Hire Me
Related Posts
Written by: David Cooley - January 11th, 2008
Posted in BloggingTags: Blogging, PHP, Programming, RSS, Troubleshooting, Wordpress, Wordpress Error, Wordpress How To, Wordpress Plugin, XML Parsing Error








This is exactly why I leave off the ?> on my php files.
Course you can’t do that when you mix HTML and php together but I think that’s a bad practice anyway.
G-Man
Bad practice has become the norm these days it seems. ASP was the same way.
I have been a frequent visitor of this blog for some time now, so I thought it would be a good idea to leave you with my thanks.
Regards,
Jim Mirkalami
Jim, Your welcome, I hope that means you are leaving your thanks, and not that you are leaving the blog.
That was pretty interesting. Thanks for sharing!
-Dre
http://monarchhp.com/blog/
I am a non-techie and after I spent 29 hours recovering from a php nightmare, all my business website visitors got to see was my phpadmin log-in page, I got this “error Invalid xml declaration. Line: 2 Character: 3″ on my sister blog feed.
Thank You for your help, I deactivated all my plug-ins, it made my life much easier. Can you tell me which plug-in is the issue though?
Michelle
@Michelle, its hard to say without looking at it. You can usually see the problem when you copy and paste it in a text editor.
I would be glad to look at it for you. Just drop me a note on my Contact Me page.
[...] have posted about this problem before, however, since the WordPress Automatic Plugin Updates (WPAU) have been working there is a new [...]
Maybe I just don’t understand, but is this why when I try to update a plugin it gives me an error stating “blah blah/blah/blah can’t be created”, “update failed”?
It happens with all plugins, not matter what.
Just curious…
-TheYoungGuy
TheYoungGuy, your problem sounds more like a permissions issue. I have never ran across that error before, but I will certainly look into it.
[...] WordPress XML Parsing Error [...]
Appreciate this! But unfortunately, I’m having the same problem. I went through every single .php file in all my plugins and couldn’t find a thing
http://takezer0.com/feed/
Sean, make sure to check ALL plugins, including ones that are not active. Also, if you still have this problem it is most likely the same issue, in one or more of the Theme files.
Sean, I just looked at your site, this error is on every page, just look at the source on the home page, you will see 4 blank lines. This leads me to believe it is in the Theme files. One way to test, select the Classic Theme, and preview it to see if there are blank lines in a different theme.
Thank you for the quick response David
I switched to the default theme and it worked! I’ll go over each theme file carefully again. Really appreciate it!
And… fixed! I had a few extra lines in my functions.php file when I changed our feed to feedburner. Thanks again!
Hi David,
In the post you said “turned them off. ” But in a comment to Sean you said deactivating was not suffient. Could you clarify?
I’ve been trying to determine which plugin it could be, but I’ve not added a new one. I did delete some though and turn some on and off this week. I’ve checked all the relevant files in c-panel for extra spaces. So far, no clue.
Would you be willing to name the plugin culprit via email just in case it’s the same one?
David, I’m not sure whether this is the same problem. I’ve been going through the forums in wordpress and haven’t been able to find a solution for this. It might have started about a week ago. I’m using feedburner. Other tools for reading the feed have no problem. Nevertheless, when I try to validate, I get this:
#
line 43, column 1: Missing enclosure attribute: length (6 occurrences) [help]
<enclosure url="http://www.imaginacionatrapada.com.ar/Teatro/wp-content/upl …
^
#
line 212, column 71: XML parsing error: :212:71: not well-formed (invalid token) [help]
http://tranviasydeseos.com.ar/index.php?option=com_content&view=arti …
what’s in 43 reads like this:
#
and 212 looks like this:
http://tranviasydeseos.com.ar/index.php?option=com_content&view=article&id=107:por-tu-padre-identidad-desconocidaq&catid=59:criticas&Itemid=100
do u have any suggestions?
thanx in advance