1

I can't use a & in the tag of rss feed item, because when I do I always get the error

error on line 1 at column 1337: EntityRef: expecting ';'

but If I don't use & in the tag then everything is ok.

E.g this doesn't work:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
  <title>Borken RSS feed</title>
  <description>Broken RSS Feed is broken.</description>
  <link>http://example.org</link>
  <lastBuildDate>Tue, 21 Jan 2012 19:13:22 +0100</lastBuildDate>
  <pubDate>Tue, 21 Jan 2012 19:13:22 +0100</pubDate>

[...]
    <link>
    https://www.youtube.com/watch?v=pH6rSul-5X8&feature=related
    </link>
    <guid>
    https://www.youtube.com/watch?v=pH6rSul-5X8&feature=related
    </guid>
[...]
Micheal Perr
  • 1,805
  • 5
  • 18
  • 24

1 Answers1

2

You have to escape all special characters. & and should look like &amp;

Using php, that would look like: htmlspecialchars($text);

Chars that need to be escaped: <, >, ", &, and possibly others...

Mārtiņš Briedis
  • 17,396
  • 5
  • 54
  • 76
  • Srsly? Isn't there anything I can add to the header of the rss Feed, because I have already seen valid rss 2.0 feeds which didn't escaped special characters.... – Micheal Perr Feb 11 '12 at 21:08
  • 1
    @MichealPerr: Those weren't valid RSS feeds - although many readers may be able to cope with them. All valid RSS feeds are XML, and XML requires that ampersands be escaped, and there's no way around it. – grahamparks Feb 11 '12 at 21:31