What is the correct MIME type to use for an RSS feed?
Asked Answered
T

7

161

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.

Tarr answered 27/2, 2009 at 16:56 Comment(0)
W
270

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

Winding answered 27/2, 2009 at 16:58 Comment(4)
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.Percale
@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.Luciennelucier
@SamuelEUSTACHI - it's not just a "de facto" standard, it's an actual standard of the IETF and IANA -- RFC 6838 points things to register with IANA, and that registry -- iana.org/assignments/media-types/media-types.xhtml -- doesn't have application/rss+xml in it. A draft was submitted, and I don't know the history of why it wasn't accepted, but I see some indications that it was considered to be poorly specified. Anyway, I think this answer is a "good" one, but also, it's not technically standards-compliant -- and there's contention various places about supporting it or not.Belak
Currently Google Chrome doesn't prettify the xml source browsed in a tab if I use application/rss+xml, it does instead if I use text/xml, just saying.Exostosis
K
45

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).

Keynote answered 9/8, 2011 at 19:13 Comment(4)
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.Keynote
In fact, the order of the elements in the Accept header is irrelevant. Preference is indicated with the q parameter, 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"Logistics
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 $fLuciennelucier
@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 🧐🐉Calkins
L
16

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.

Luciennelucier answered 19/4, 2016 at 3:44 Comment(2)
Haven't checked the others, but bbci.co.uk is now sending application/rss+xmlSaundrasaunter
This answer seems... not exactly cherry-picked, maybe, but at least incomplete. It's also out of date. Adding a -L to the curl line, I now get 5 text/xml, 2 application/xml, 1 text/html, and 1 application/rss+xml. I also get application/rss+xml for savage.love/feed, application/xml for feeds.serialpodcast.org/serialpodcast -- though that gets linked as <link rel="alternate" type="application/rss+xml" title="Podcast" href="http://feeds.serialpodcast.org/serialpodcast" />, etc. So, I don't think the "pretty much all" statement is really fair.Belak
J
11

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

Jaynes answered 27/4, 2017 at 11:1 Comment(4)
I do not think application/rss+xml has any practical compatibility issues, so there is no point to use xml mimetype.Marylynnmarylynne
@MikkoOhtamaa old browsers may render incorrectly because they don't recognize the mime. with application/xml almost all browsers will display an xml document tree instead of plain text / htmlJaynes
But you are not using browsers to render RSS in the first place, you are using RSS readers.Marylynnmarylynne
Upvoted, always good to see what the W3C says about a situation, even if it's not necessarily perfect advice (if such a thing exists).Malodorous
C
3

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.

Company answered 9/12, 2010 at 23:42 Comment(0)
L
1

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

Lovett answered 27/2, 2009 at 17:3 Comment(1)
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.Dysphasia
U
0

There is also JSON feeds: application/feed+json

Use answered 25/11, 2023 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.