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).
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 to 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.
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
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.
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.