DEV Community

Salma Alam-Naylor
Salma Alam-Naylor

Posted on • Originally published at whitep4nth3r.com

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>
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)