XML parsing failed error when sitemap.xml is called via browser
WPMU DEV Community
XML parsing failed error when sitemap.xml is called via browser
Elite
18 pointsStarting to get into this DEV thingI'm new here
johnol
Member
—
7th January 2012 (4 months ago)
In certain customer cases, we have been forced to embed Javascript calls within a given menu item from the site menu. This largely has to do with 3rd party integration of certain functions.
We were previously using the Google XML Sitemaps plugin which seemed to handle this very well: The Google XML Sitemaps plugin would parse the javascript and display it (without all of the link info).
As you are probably aware, the Google XML Sitemaps plugin is not yet compatible with Multi-Site (There is a version working through beta testing right now but it has its own problems.)
Since that plugin doesn't work with Multi-Site, we decided to give Simple Sitemaps a try.
The problem we are having is that Simple Sitemaps is trying to display all of the Javascript details and is generating the XML parsing error as a result.
Here is an example of the error:
XML parsing failed
XML parsing failed: syntax error (Line: 129, Character: 76)
In certain customer cases, we have been forced to embed Javascript calls within a given menu item from the site menu. This largely has to do with 3rd party integration of certain functions.
We were previously using the Google XML Sitemaps plugin which seemed to handle this very well: The Google XML Sitemaps plugin would parse the javascript and display it (without all of the link info).
As you are probably aware, the Google XML Sitemaps plugin is not yet compatible with Multi-Site (There is a version working through beta testing right now but it has its own problems.)
Since that plugin doesn't work with Multi-Site, we decided to give Simple Sitemaps a try.
The problem we are having is that Simple Sitemaps is trying to display all of the Javascript details and is generating the XML parsing error as a result.
Here is an example of the error:
XML parsing failed
XML parsing failed: syntax error (Line: 129, Character: 76)
10635 pointsLike some sort of WPMU DEV GodMindblowingly helpful memberLifetime member
Sales & Support Lead
—
9th January 2012 (4 months ago)
#
Hiya johnol,
I'm gonna ask the developer if he has any thoughts on this one. We also offer our Infinite SEO plugin which handles sitemaps for multisite and is more frequently updated: http://premium.wpmudev.org/project/infinite-seo
7259 pointsLike some sort of WPMU DEV GodMindblowingly helpful memberLifetime member
Support Chimp
—
18th January 2012 (4 months ago)
#
Hey there! :-)
Just checking in to see how things are going. :-)
We haven't heard form you on this in a while. So I'm going to presume your all fixed up now and don't need any further assistance.
However if you have more questions or need some more help then please feel free to respond in this thread or create a new one and we will be more than happy to offer assistance. :-)
Still waiting to hear back from the developer regarding the XML parsing error shown above for this plugin. My lack of activity is simply me trying to patiently wait for an answer from your team.
The parsing error you're seeing seems to be related to an unescaped ampersand ("...&tokenid=..."). Ampersands have special meaning in XML, as they denote the XML entities (e.g. > or <). Could you please try to rewrite the link using "&" instead of the plain "&"?
I am using Simple Sitemaps.
What do you mean delete it? Is there an actual file being created? I thought Simple Sitemaps creates a virtual sitemap file?
Actually, Simple Sitemaps creates a file in your blogs.dir, under files subdirectory. If it doesn't exist yet (i.e. on the first run), it will print out the dynamically generated content, but it will also cache the results in the file.
Having said that, it is very possible that a piece of code (a plugin or a theme) is echoing some whitespace characters (a line break) before the cached file (or dynamic output) is rendered by Simple Sitemaps. This would typically be caused by a trailing line break in a PHP file after the closing PHP tag.
I deleted the sitemap file for the main blog, opened zice.ro/sitemap.xml in my browser and all I get is: plugin missing? the sitemap.xml file isn't being generated again.
network deactivate the plugin network activated it again and still the same: no sitemap is being generated again...
It means that, after attempting to load the WordPress environment, the sitemap output/generation handler (sitemap.php) is unable to find the main class. Just a quick check, do you have sitemap.php file copied to your wp-content directory? If you do, are you perhaps using a different file structure then usual (i.e. moved root directory)?
Having said that, it is very possible that a piece of code (a plugin or a theme) is echoing some whitespace characters (a line break) before the cached file (or dynamic output) is rendered by Simple Sitemaps. This would typically be caused by a trailing line break in a PHP file after the closing PHP tag.
any hint as to what type of plugin could be interfering? I don't run any other plugins that deal with sitemaps...
I jsut checked my .htaccess file and found this line:
I'm sorry, I haven't explained very well what I believe is happening. By the time the sitemap is about to be sent to your browser, a newline was already sent and thus, the XML declaration will come as a second line, not the first. This scenario also fully explains your screenshot and the discrepancy between the file on the server and what you get in your browser.
Now, about the origin of the newline - this is most likely a trailing newline character (after the closing PHP tag) in one of your PHP files, very likely a plugin. If a PHP file has anything in it after the closing tag, that content will be sent to the browser just by including the file (it's actually a bit more complicated then that, but basically that's what happens if we rule out buffering). The best approach would be either deactivating plugins one by one and testing if the newline disappeared from the output. If this is not possible, you can also check the files yourself, and see if there are any newlines after the closing PHP tags in them.
ah, I do understand now.
unfortunately there are too many plugins to deactivate one by one and it is a live site.
thinking of alternate methods of detecting the faulty plugin, shouldn't a plugin with an empty line behind the closing php tag throw some warning/error/notice into my logs? can't find anything there :-(
gonna read up on some linux manuals to see if there is a command line method of finding files with an empty line after the closing php tag, if anyone has any knowledge about this I'd be very grateful :-)
Just saw your previous post, I missed it earlier as I was typing my response :) The .htaccess rule is still needed for Simple Sitemaps, and it's a good thing you already have it in place. Also, any character outside the opening and closing PHP tags is perfectly valid, so it wouldn't appear in error logs. For finding the file that causes the newline output, you may want to look into grep tool but, depending on how you craft your regular expression for search, it's likely you'll see quite a few false positive results.
just manually edited all plugin files that were network activated and inside mu-plugins and removed countless empty lines after closing php statements. didn't go into any subfolders though but the problem still persists :-(
not sure what to do now.
does the newer SEO plugin you guys offer here use the same technology or could that fix the problem by replacing Simple Sitemaps for Multisite with Infinite SEO fix this?
I never wanted to use Infinite SEO because the Simple Sitemaps for Multisite is all I need but if that will help, I will have to repalce it.
yes mason its solved, that plugin was the only reason for the probbs. removed those lines and everything is fine now: the sitemaps work, all the feeds work again (they had the same problem with validation)
Responses (26)
Sales & Support Lead — 9th January 2012 (4 months ago) #
Hiya johnol,
I'm gonna ask the developer if he has any thoughts on this one. We also offer our Infinite SEO plugin which handles sitemaps for multisite and is more frequently updated:
http://premium.wpmudev.org/project/infinite-seo
Thanks!
Member — 11th January 2012 (4 months ago) #
Thanks. Does infinite SEO auto-submit to Google / Bing / Ask when it updates the sitemap.xml?
Sales & Support Lead — 11th January 2012 (4 months ago) #
Infinite SEO does auto-submit, but on a multisite install you have the option of disabling this and then doing it manually whenever necessary.
The options for this are at the bottom of the Sitemaps page (Step 2). Thanks.
Support Chimp — 18th January 2012 (4 months ago) #
Hey there! :-)
Just checking in to see how things are going. :-)
We haven't heard form you on this in a while. So I'm going to presume your all fixed up now and don't need any further assistance.
However if you have more questions or need some more help then please feel free to respond in this thread or create a new one and we will be more than happy to offer assistance. :-)
Take care.
Member — 19th January 2012 (4 months ago) #
Still waiting to hear back from the developer regarding the XML parsing error shown above for this plugin. My lack of activity is simply me trying to patiently wait for an answer from your team.
Sales & Support Lead — 20th January 2012 (4 months ago) #
Apologies for the delay. Let me go wake Vlad :)
Thanks!
Developer — 20th January 2012 (4 months ago) #
Hello,
The parsing error you're seeing seems to be related to an unescaped ampersand ("...&tokenid=..."). Ampersands have special meaning in XML, as they denote the XML entities (e.g. > or <). Could you please try to rewrite the link using "&" instead of the plain "&"?
Member — 20th January 2012 (4 months ago) #
got a very similar problem here:
http://zice.ro/sitemap.xml or here
http://sarcasticu.zice.ro/sitemap.xml
open in browser gives error:
feed validator check here: http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fsarcasticu.zice.ro%2Fsitemap.xml
it seems the first line is empty and the second line contains the XML declaration.
any fixes?
Sales & Support Lead — 23rd January 2012 (4 months ago) #
Hiya Ovidiu,
Are you using Infinite SEO or simple sitemaps there?
That is odd to have a blank line at the start. I suppose you've already tried deleting it and recreating it? ;)
Member — 24th January 2012 (4 months ago) #
I am using Simple Sitemaps.
What do you mean delete it? Is there an actual file being created? I thought Simple Sitemaps creates a virtual sitemap file?
Member — 26th January 2012 (3 months ago) #
any other ideas guys?
Developer — 27th January 2012 (3 months ago) #
Hi,
Actually, Simple Sitemaps creates a file in your blogs.dir, under files subdirectory. If it doesn't exist yet (i.e. on the first run), it will print out the dynamically generated content, but it will also cache the results in the file.
Having said that, it is very possible that a piece of code (a plugin or a theme) is echoing some whitespace characters (a line break) before the cached file (or dynamic output) is rendered by Simple Sitemaps. This would typically be caused by a trailing line break in a PHP file after the closing PHP tag.
Member — 27th January 2012 (3 months ago) #
ok, help me out a bit please:
I deleted the sitemap file for the main blog, opened zice.ro/sitemap.xml in my browser and all I get is: plugin missing? the sitemap.xml file isn't being generated again.
network deactivate the plugin network activated it again and still the same: no sitemap is being generated again...
what does it mean by plugin missing?
Developer — 27th January 2012 (3 months ago) #
Hi,
It means that, after attempting to load the WordPress environment, the sitemap output/generation handler (sitemap.php) is unable to find the main class. Just a quick check, do you have sitemap.php file copied to your wp-content directory? If you do, are you perhaps using a different file structure then usual (i.e. moved root directory)?
Member — 27th January 2012 (3 months ago) #
yes sitemap.php is inside wp-content and my site structure hasn't been modified.
Member — 27th January 2012 (3 months ago) #
slightly confused: http://screencast.com/t/xMnfspkSqNZ
if I edit the sitemap.xml file via my ssh console the 1st line isn't empty !?
any other advice you can give me?
Member — 27th January 2012 (3 months ago) #
any hint as to what type of plugin could be interfering? I don't run any other plugins that deal with sitemaps...
I jsut checked my .htaccess file and found this line:
RewriteRule ^(.*/)?sitemap.xml wp-content/sitemap.php [L]is that still necessary for this plugin? it might be a leftover from previous versions...
Developer — 27th January 2012 (3 months ago) #
I'm sorry, I haven't explained very well what I believe is happening. By the time the sitemap is about to be sent to your browser, a newline was already sent and thus, the XML declaration will come as a second line, not the first. This scenario also fully explains your screenshot and the discrepancy between the file on the server and what you get in your browser.
Now, about the origin of the newline - this is most likely a trailing newline character (after the closing PHP tag) in one of your PHP files, very likely a plugin. If a PHP file has anything in it after the closing tag, that content will be sent to the browser just by including the file (it's actually a bit more complicated then that, but basically that's what happens if we rule out buffering). The best approach would be either deactivating plugins one by one and testing if the newline disappeared from the output. If this is not possible, you can also check the files yourself, and see if there are any newlines after the closing PHP tags in them.
Member — 27th January 2012 (3 months ago) #
ah, I do understand now.
unfortunately there are too many plugins to deactivate one by one and it is a live site.
thinking of alternate methods of detecting the faulty plugin, shouldn't a plugin with an empty line behind the closing php tag throw some warning/error/notice into my logs? can't find anything there :-(
gonna read up on some linux manuals to see if there is a command line method of finding files with an empty line after the closing php tag, if anyone has any knowledge about this I'd be very grateful :-)
Developer — 27th January 2012 (3 months ago) #
Just saw your previous post, I missed it earlier as I was typing my response :) The .htaccess rule is still needed for Simple Sitemaps, and it's a good thing you already have it in place. Also, any character outside the opening and closing PHP tags is perfectly valid, so it wouldn't appear in error logs. For finding the file that causes the newline output, you may want to look into grep tool but, depending on how you craft your regular expression for search, it's likely you'll see quite a few false positive results.
Member — 27th January 2012 (3 months ago) #
no luck.
just manually edited all plugin files that were network activated and inside mu-plugins and removed countless empty lines after closing php statements. didn't go into any subfolders though but the problem still persists :-(
not sure what to do now.
does the newer SEO plugin you guys offer here use the same technology or could that fix the problem by replacing Simple Sitemaps for Multisite with Infinite SEO fix this?
I never wanted to use Infinite SEO because the Simple Sitemaps for Multisite is all I need but if that will help, I will have to repalce it.
Member — 28th January 2012 (3 months ago) #
Does anyone else have another idea how to identify the faulty plugin?
I just realized all blogs hosted, every single page or post has a blank first line in the pages source code :-(
Have a nice weekend everyone :-)
Member — 29th January 2012 (3 months ago) #
many, many hours later I found the culprit: http://wordpress.org/extend/plugins/replace-diacritics/
not the main plugin file but another php file that is part of the plugin too had several empty lines after the last closing statement :-(
Sales & Support Lead — 2nd February 2012 (3 months ago) #
Gads Ovidiu, what a lousy experience :(
Were you able to resolve the issue now? Or is it ongoing? Let us know. Thanks!
Member — 2nd February 2012 (3 months ago) #
yes mason its solved, that plugin was the only reason for the probbs. removed those lines and everything is fine now: the sitemaps work, all the feeds work again (they had the same problem with validation)
all is good now.
Sales & Support Lead — 2nd February 2012 (3 months ago) #
Whew. Glad to hear it. Thanks for letting us know :)
Become a member