144

Is one MIME type preferable to ensure compatibility with RSS readers and other scrapers?

The options seem to be:

  • text/xml
  • text/rss+xml

Interestingly Stackoverflow is using text/html.

Steve Claridge
  • 9,202
  • 8
  • 30
  • 33

7 Answers7

244

Neither. It's application/rss+xml http://www.rssboard.org/rss-mime-type-application.txt

vartec
  • 118,560
  • 34
  • 206
  • 238
  • 8
    I agree this is the correct type, however, it does not seem to be well understood by web browsers. It looks like (sadly) text/xml is now a de facto standard. – Samuel EUSTACHI Feb 18 '13 at 15:35
  • 1
    @SamuelEUSTACHI you are right, and the accepted answer is probably not the best to ensure compatibility, as requested. Tim Bray back in 2003: "one way or an­oth­er I think it's prob­a­bly im­por­tant that the com­mu­ni­ty get its act to­geth­er and de­cide what Media-type to use and start us­ing it". Today: see my answer below for evidence that pretty much *all* popular feeds use `text/xml`. – Kai Carver Apr 19 '16 at 03:54
38

Other commenters have pointed out that the single correct mime type is application/rss+xml,.

However, if you are setting an accept header for a client then

Accept: application/rss+xml, application/rdf+xml;q=0.8, application/atom+xml;q=0.6, application/xml;q=0.4, text/xml;q=0.4

might be a good choice, as it states that it accepts RSS, Atom, and XML (in descending order or preference).

Ruben Verborgh
  • 3,406
  • 2
  • 28
  • 41
Robert MacLean
  • 38,077
  • 24
  • 96
  • 147
  • 3
    The accept header order tells the server what content to use. Server will see if it can offer that the first, then the second etc... That is why the "application/rss+xml" is the best first choice and "text/xml" as a final fallback is is good. – Robert MacLean Jul 06 '13 at 17:07
  • 4
    In fact, the order of the elements in the Accept header is irrelevant. [Preference is indicated with the `q` parameter](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1), so for the desired effect it would be better to send `Accept: application/rss+xml, application/rdf+xml, application/atom+xml, application/xml;q=0.9, text/xml;q=0.8`, which means "Prefer any of the correct MIME types for feeds. If you can't offer that, prefer `application/xml`. If you can't offer that, prefer `text/xml`. Otherwise, just give me what you've got" – Magnus Hoff Oct 26 '15 at 10:02
  • 1
    For what it's worth, I tried both of the suggested forms of `Accept` headers with the examples of popular feeds in my answer below, and they all returned `text/xml`. I used the command: `curl -s -H 'Accept: application/rss+xml, application/rdf+xml, application/atom+xml, application/xml;q=0.9, text/xml;q=0.8' -H 'Content-Type: application/rss+xml' -I $f` – Kai Carver Apr 19 '16 at 04:16
  • @KaiCarver I've been working on a new project built with ASP.NET Core 3.1 Web API + Angular 9. I needed to generate an RSS feed and when comparing the output to other websites, I realized the correct Content-Type to use is text/xml. However the HTML content in the description nodes were being escaped, setting the Accept header values resolved the issue. Thank you, cheers – Nexus Apr 11 '20 at 08:52
13

Here's a pragmatic answer: whatever the "correct" answer may be (and clearly there is debate about this), text/xml is the type used by pretty much all the popular feeds out there in the wild.

Here are a few that I checked:

$ for f in \
  https://feeds.feedburner.com/TechCrunch/ \
  http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml \
  http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml \
  https://daringfireball.net/thetalkshow/rss \
  http://www.npr.org/rss/podcast.php?id=381444908 \
  http://feeds.serialpodcast.org/serialpodcast \
  http://podcasts.joerogan.net/feed \
  https://feeds.feedburner.com/thetimferrissshow \
  http://feed.thisamericanlife.org/talpodcast ; do \
  curl -s -I $f | fgrep -i Content-Type: ; done
content-type:text/xml; charset=UTF-8
Content-Type: text/xml
Content-Type: text/xml
Content-Type: text/xml;charset=UTF-8
Content-Type: text/xml;charset=UTF-8
Content-Type: text/xml; charset=UTF-8
Content-Type: text/xml; charset=UTF-8
content-type:text/xml; charset=UTF-8
Content-Type: text/xml; charset=UTF-8

So you can be sure that text/xml will be correctly interpreted by commonly used RSS clients.

Kai Carver
  • 1,954
  • 24
  • 23
5

The most correct is application/rss+xml

The most compatible is application/xml

According to W3C:

RSS feeds should be served as application/rss+xml (RSS 1.0 is an RDF format, so it may be served as application/rdf+xml instead). Atom feeds should use application/atom+xml. Alternatively, for compatibility with widely-deployed web browsers, any of these feeds can use one of the more general XML types - preferably application/xml.

https://validator.w3.org/feed/docs/warning/UnexpectedContentType.html

nggit
  • 411
  • 5
  • 5
2

Go for MIME application/rss+xml to be safe if you want to make sure your feed is compatible with RSS readers and other scrapers. That's what I use.

1

You could use text/xml, but the correct MIME type would be application/rss+xml.

Cerebrus
  • 25,080
  • 8
  • 54
  • 70
  • 3
    `application/xml` is prefered over `text/xml` because XML doesn't follow normal text content encoding rules. It can embed its encoding in its data, which will cause problems if proxies try to blindly transcode the text. In other words, proxies are instructed to preserve the data byte-for-byte. – Zenexer May 27 '14 at 12:16
-2

text/xml is the only correct answer. Mime types are a registration based system. There is an official list managed by IANA (Internet Assigned Numbers Authority) at http://www.iana.org/assignments/media-types/media-types.xhtml

Monkey Code
  • 544
  • 6
  • 19
  • 1
    Not all MIME types in the world are registered with IANA. More importantly, nothing in that document suggests usage for RSS. – Ruben Verborgh Feb 20 '16 at 19:54
  • RSS is XML. It suggests usage for XML. – Monkey Code Feb 21 '16 at 19:07
  • 2
    That argument is insufficient. RSS is also RDF. XML is also text. So by this reasoning, an RDF or text MIME type could also be good. However, the trouble is that not all XML documents are RSS. So a generic XML type is not specific enough to unambiguously identify RSS. – Ruben Verborgh Feb 22 '16 at 08:04
  • @RubenVerborgh "nothing in that document suggests usage for RSS" I used Ctrl + F and I typed in application/atom and it found application/atom+xml as one of the MIME types. I don't know about other namespaces. However, I think application/rss+xml is the best for 2.0, no matter what the namespace is. – MaxxiBoi Jan 30 '18 at 21:36