Skip to main content

How to fix error: invalid character in entity name in RSS feeds

I use a GitHub action to update my GitHub profile README with my latest blog posts. For over a week the job had been failing, and I ignored it (rookie mistake). It turns out I had broken my RSS feed when I edited some blog post descriptions and used a character that wasn't valid in XML (referred to as an invalid token).

The error in the GitHub action workflow run wasn't very helpful, though: "Error: Invalid character in entity name". 🫠

Error feed.xml runner failed, please verify the configuration. Error: invalid character in entity name. Line 1579. Column 152. Char not specified. 0 blog posts fetched.

Luckily, the RSS Feed Validation Service provided by W3C gave a better error report.

Sorry. This feed does not validate. Line 1597, column 151: XML parsing error, not well-formed (invalid token). The line that broke it was: information to screen-readers & (ampersand) assistive tech in the description tag.

This helped me track down the invalid character to an ampersand (&), which I added to a blog post description a week ago to reduce the character count. The resulting invalid description tag in the XML document looked like this:

<item>
<title>When to use aria-labels in your HTML</title>
<description>This is one of the most important ways to use aria-labels so your code provides contextual information to screen-readers & assistive tech.
</description>
</item>

I did some further reading on XML and learned that ampersands, and left and right angled brackets (< and >) must be escaped in XML in order for the document to be valid, unless wrapped in a CDATA section. Read more about XML character data and markup on the official W3C docs.

Read more on this topic

21 Mar 2022

Tutorials 2 min

How to format dates for RSS feeds (RFC-822)

Here's a selection of links, guidance and code snippets to help you format dates for RSS feeds (RFC-822).

27 May 2021

Tutorials 4 min

How to use GitHub actions and Contentful webhooks to show your latest blog posts on your GitHub README

Want to show your latest blog posts on your GitHub README? Here's how I do it using the power of GitHub actions and webhooks in Contentful.