首页 文章

用于RSS提要的正确MIME类型是什么?

提问于
浏览
120

是否有一种MIME类型可以确保与RSS阅读器和其他搜索器的兼容性?

选项似乎是:

  • text / xml

  • text / rss xml

有趣的是Stackoverflow正在使用text / html .

7 回答

  • 12

    都不是 . 这是 application/rss+xml http://www.rssboard.org/rss-mime-type-application.txt

  • 29

    其他评论者指出,单个正确的mime类型是 application/rss+xml, .

    但是,如果您正在为客户端设置接受标头

    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

    可能是一个不错的选择,因为它声明它接受RSS,Atom和XML(按降序或首选项) .

  • 4

    这是一个实用的答案:无论回答是什么(显然存在争议), text/xml 是野外几乎所有流行的饲料使用的类型 .

    以下是我检查的一些内容:

    $ 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
    

    因此,您可以确保 text/xml 将被常用的RSS客户端正确解释 .

  • 2

    correctapplication/rss+xml

    compatibleapplication/xml

    根据W3C:

    RSS提要应该作为application / rss xml提供(RSS 1.0是一种RDF格式,因此它可以作为application / rdf xml使用) . Atom提要应该使用application / atom xml . 或者,为了与广泛部署的Web浏览器兼容,这些源中的任何一个都可以使用一种更通用的XML类型 - 最好是application / xml .

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

  • 1

    如果您想确保您的Feed与RSS阅读器和其他裁剪器兼容,请选择MIME application/rss+xml以确保安全 . 这就是我使用的 .

  • -1

    您可以使用 text/xml ,但正确的MIME类型将是 application/rss+xml .

  • 214

    text/xml 是唯一正确的答案 . Mime类型是基于注册的系统 . IANA(互联网号码分配机构)管理的官方列表位于http://www.iana.org/assignments/media-types/media-types.xhtml

相关问题