いももちのきもち

悪戦苦闘の歴史のメモ

xmlのContent-Typeはapplication/xmlか、それともtext/xml?

気になったので調べた。

結論

どちらでもよい、が、application/xmlを推奨。

根拠

RFC3023(2001年)にはapplication/xmltext/xmlの使い分けについてガイドラインがあったが、RFC3023はRFC7303(2014年)に置き換えられている。RFC7303の§9.2によれば、XML document entitiesは

   The registration information for text/xml is in all respects the same
   as that given for application/xml above (Section 9.1), except that
   the "Type name" is "text".

つまりtext/xmlは、application/xmlの"application"を"text"に置き換えただけだと言っています。
しかしRFC7303の§4.1で過去の使い分けと混乱しないようにapplication/xmlを使用するべきとも言っています。

However, application/xml and application/xml-
external-parsed-entity are still RECOMMENDED, to avoid possible
confusion based on the earlier distinction. 


実際に使うときはcharsetも指定しましょう。
Content-Type: application/xml; charset="UTF-8"