Include & ampersand character in sitemap XML

In this post, I describe how to fix a sitemap error that can occur if an unescaped character such as an & (ampersand) is included in the sitemap.xml.

Screenshot of error "Sitemap can be read, but has errors"


Cause

The error occurs because the sitemap is not UTF-8 encoded.  In my case, I had a URL with an unescaped & (ampersand):

<url><loc>https://www.centrel-solutions.com/company/testimonial.aspx?directory=education&testimonial=education-the-shared-learning-trust</loc><changefreq>never</changefreq></url>


Resolution

To resolve the error, I used an entity escape code for the & (ampersand) character as per the sitemaps specification:

https://www.sitemaps.org/protocol.html

<url><loc>https://www.centrel-solutions.com/company/testimonial.aspx?directory=education&amp;testimonial=education-the-shared-learning-trust</loc><changefreq>never</changefreq></url>


Validate

You can validate a sitemap here:

https://www.xml-sitemaps.com/validate-xml-sitemap.html

Screenshot showing the sitemap is valid

Comments

Popular posts from this blog

LG TV This app will now restart to free up more memory

LG TV Clear All Browsing History Data

Excel Import CSV not using "Use First Row as Headers"