CorrectFeed

RSS feed invalid XML error: how to fix parsing failures

If your RSS feed has an invalid XML error, the feed is broken at the parser level.

That usually means one of these is present:

  • an unescaped &
  • a malformed tag
  • a broken CDATA section
  • invalid characters or bad encoding
  • embedded markup that is not safe in XML

Quick answer

Most invalid XML feed errors come down to one malformed character or one malformed entry.

The fastest workflow is:

  1. capture the first parser error
  2. fix that exact spot
  3. validate again
  4. repeat until the feed parses cleanly

Common RSS invalid XML errors

EntityRef: expecting ';'

This usually means & was used without being escaped as &.

Example:

Bad:

<title>R&D updates</title>

Good:

<title>R&amp;D updates</title>

not well-formed (invalid token)

This usually points to an invalid character, encoding problem, or malformed byte sequence.

mismatched tag

This usually means a tag was opened and not closed correctly, or embedded markup inside an item broke the XML structure.

XML declaration allowed only at the start of the document

This usually means there is stray output, whitespace, or a byte-order-mark problem before the XML declaration.

The most common causes

1. Unescaped characters

The classic case is an unescaped ampersand.

Other common mistakes:

  • raw HTML entities like &nbsp;
  • unescaped characters inside attributes
  • pasted URLs or titles that contain &

In XML feeds, named HTML entities like &nbsp; are usually invalid unless explicitly defined. Numeric references or real characters are safer.

2. Malformed embedded markup

If your feed includes HTML in <description> or <content:encoded>, broken markup inside one item can break the entire feed.

Examples:

  • unclosed tags
  • raw <script> or <style> blocks
  • mismatched HTML fragments

3. Broken CDATA sections

CDATA must be opened and closed correctly.

A stray ]]> or broken wrapper can make the whole XML document invalid.

4. Encoding problems

If the feed declares UTF-8 but contains bytes that are not valid UTF-8, many parsers will reject it.

Things to check:

  • the XML declaration matches the real encoding
  • no hidden control characters were copied in
  • the publishing system is not mixing encodings

5. One bad item breaking everything

A feed can fail because of a single malformed entry.

That is why the first parser error matters so much. Once you fix it, the next hidden issue often appears.

Practical troubleshooting flow

Step 1: capture the first error

Use a validator and start with the first line and column it reports.

Step 2: inspect a few characters around that location

Look for:

  • & that should be &amp;
  • broken tags
  • malformed CDATA
  • weird invisible characters

Step 3: fix only that issue first

Do not try to rewrite everything at once. XML errors often cascade.

Step 4: validate the live endpoint again

Use:

If the feed is still invalid, move to the next reported parser error.

When this page should hand off to other pages

Use this page for the exact problem: feed parser says the XML is invalid.

If the actual issue turns out to be:

Prevent future invalid XML errors

  • generate feed XML with a real serializer when possible
  • sanitize titles and descriptions before inserting them
  • keep embedded markup simple
  • validate after deploys
  • add a CI or build check that fails on malformed XML

FAQ

Why does my RSS feed say invalid XML?

Usually because of one malformed character or tag, such as an unescaped ampersand, broken CDATA section, invalid control character, bad encoding, or mismatched XML tags.

What does 'EntityRef: expecting ;' mean in a feed?

It usually means an ampersand was used without being escaped as &amp; inside XML text or an attribute.

Can one malformed item break the entire feed?

Yes. One malformed entry can make the full RSS or Atom document unparsable to many validators and readers.

Fix RSS/Atom feeds and OPML lists

Paste a feed/OPML URL, upload a file, or paste XML — then validate and fix it.

Fix my feed / Import OPML Back to Help