HowTo: Fix XML Parsing Error: Not Well-Formed Sitemap.xml

It really helps when you do routine maintenance checkups on your blog or website. While performing a checkup on JaypeeOnline earlier today, I was surprised to find out that the sitemap wasn’t working. Whenever I tried to access it, I would get this error message: XML Parsing Error: not well-formed (see screenshot below).

xml parsing error

Since I was using the Yoast SEO plugin (formerly WordPress SEO) to generate my sitemap, I checked the configuration/settings to see if there was something wrong there but everything checked out fine. So the next thing I did was try to disable-enable the XML sitemap functionality to allow the plugin to rebuild the sitemap and see if that can fix the problem. It didn’t.

I logged in to the WordPress support forums to see if anyone had a solution for the XML Parsing Error. I found out that this was a bit common, especially for users who were using both the Yoast SEO plugin and the W3 Total Cache plugin. I tried disabling the Minify Javascripts option on W3 Total Cache and the sitemap worked! It verified what other users mentioned about it being an issue caused by a conflict between those two plugins.

Several posts suggested adding some lines of code to the .htacces file. I tried them and the XML Parsing Error disappeared but now I was getting an ERROR 404 or Page not found error. I went to the Yoast Knowledge Base to see if they had a solution to this problem. The documentation suggested adding the following code into the .htaccess file.

# WordPress SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix

So I edited my .htaccess file and added the code, emptied all caches. I tried to access the sitemap and I still got a 404.

After spending a few more minutes looking for a solution, I finally found one that worked. So if you’re getting the XML Parsing Error: not well-formed error message when trying to access your sitemap, try this:

  • Login to your WordPress dashboard.
  • Go to the Minify section of W3 Total Cache – Performance > Minify
  • Scroll down into the Advance section.
  • Look for “Never minify the following pages:
  • Copy & paste the following lines of code inside the box.
  • Click on Save all settings.
  • Empty all caches.

That’s it! Your sitemap should be up and running. This is what I did to fix the XML Parsing Error: not well-formed issue that I had with my sitemap. Hope this tutorial was able to help you.

Has anyone else experienced getting the XML Parsing Error when trying to access your sitemap? Were you using both the Yoast SEO and W3 Total Cache plugins? Please share your thoughts by leaving a comment below.

This post may contain affiliate links that allow us to earn commissions at no additional cost to you. We are reader-supported so when you buy through the affiliate links, you are also helping or supporting us. 


  1. Thank you for your detailed instruction but I still have a problem with the sitemap generated by Yoast. Although the sitemaps of posts & categories work perfectly, the one of pages has the same error as you described in the post. I have tried many ways but still cannot fix it. It would be really appreciated if you could help me figure it out. Thank you so much!

  2. Not using WordPress for my site. Entire site is built with html. Have Sitemap.xml submitted to google but having parsing error in sitemap by google. How do I fix it?

  3. Thank you for taking the time to post this – we had this error on the site I manage but it looks like following your advice has cleared it up. You’ve been a real help to me!

  4. 100% fix to my problem with sitemap in Yoast. I tried switching off various plug-ins because i suspected plug-in interaction was the source of the problem. Fortunately I didn’t waste too much time before I found your solution. Thanks a lot.

  5. Thanks for this detailed post, but didn’t work for me. I disabled minify all together and got my sitemap back. I have previously installed heaps of plugins just to remove the “Render-blocking” java scripts. Probably conflict among plugins caused the sitemap problem….thanks for the post again

Leave a Reply

Your email address will not be published. Required fields are marked *