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.
  • sitemap(_index|[0-9]+)?.xml(.gz)?

  • 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.

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.

JaypeeOnline is supported by its audience. When you click on the advertisements or purchase through links on our site, we may earn an affiliate commission. Learn more



Owner and editor of JaypeeOnline. Self-proclaimed geek. New media writer and consultant. WordPress advocate. Loves blogging, gadgets, video games and sports. You can follow him on Facebook or Twitter.


  • Hung Ha, October 23, 2020 @ 12:40 PM Reply

    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!

    • JP Habaradas, October 23, 2020 @ 6:42 PM Reply

      @Hung – Do you use any kind of caching plugin for your WordPress site?

  • Joe garden, January 5, 2019 @ 8:19 PM Reply

    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?

  • Rohit Roy, August 29, 2016 @ 1:49 PM Reply

    Awesome this code is work like charm…. Thanks man for sharing.

  • Richard, July 27, 2016 @ 7:54 AM Reply

    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!

    • JP Habaradas, July 27, 2016 @ 3:34 PM Reply

      You’re most welcome! Glad to be of help. This is why we share these types of posts/tutorials, so we can help users like you.

  • SteveFGI, April 25, 2016 @ 4:17 PM Reply

    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.

    • JP Habaradas, July 27, 2016 @ 3:33 PM Reply

      You’re welcome! Glad to hear that this tutorial was able to help you.

  • crystal, January 12, 2016 @ 5:17 AM Reply

    Awesome thank you!!

  • ebizguy, October 14, 2015 @ 9:59 AM Reply

    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

    • JP Habaradas, January 12, 2016 @ 3:02 PM Reply

      You’re welcome! The more plugins used, the more complicated things become and more difficult to figure out or pinpoint the cause.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.