我应该为XML网站地图发送什么Content-Type值?

我想我应该发送“text / xml”,但后来我读到,我应该发送“application / xml”。有关系吗?有人可以解释差别吗?
如果charset参数为ommitted,则 difference between text/xml and application/xml是缺省字符编码:

Text/xml and application/xml behave differently when the charset
parameter is not explicitly specified. If the default charset (i.e.,
US-ASCII) for text/xml is inconvenient for some reason (e.g.,bad web
servers),application/xml provides an alternative (see “Optional
parameters” of application/xml registration in Section 3.2).

对于text/xml

Conformant with [RFC2046],if a text/xml entity is received with
the charset parameter omitted,MIME processors and XML processors
MUST use the default charset value of “us-ascii”[ASCII]. In cases
where the XML MIME entity is transmitted via HTTP,the default
charset value is still “us-ascii”.

对于application/xml

If an application/xml entity is received where the charset
parameter is omitted,no information is being provided about the
charset by the MIME Content-Type header. Conforming XML
processors MUST follow the requirements in section 4.3.3 of [XML]
that directly address this contingency. However,MIME processors
that are not XML processors SHOULD NOT assume a default charset if
the charset parameter is omitted from an application/xml entity.

因此,如果省略charset参数,则text / xml的字符编码为US-ASCII,而使用application / xml,可以在文档本身中指定字符编码。

现在在互联网上的一个经验法则是:“严格输出,但容忍输入。”这意味着确保在通过互联网传递数据时尽可能地满足标准。但是建立一些机制来忽略错误或在通过互联网接收和解释数据时猜测。

所以在你的情况下,只是选择两种类型之一(我推荐application / xml),并确保正确指定使用的字符编码(我建议使用相应的默认字符编码,以安全,所以在application / xml使用情况下UTF-8或UTF-16)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


xml怎么加入图片路径
rss源错误怎么解决
文件后缀xml是什么意思
xml格式电子发票怎么获取
xml格式是什么意思
rss是什么意思啊
xml格式电子发票怎么打开
rss订阅源是什么意思
rss源是什么
xml注释怎么写
php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类