读书人

application/xml and text/xml的差异

发布时间: 2012-10-08 19:54:56 作者: rapoo

application/xml and text/xml的区别

application/xml and text/xml的区别?经常看到有关xml时提到"application/xml" 和 "text/xml"两种类型, 二者功能一模一样,唯一的区别就是编码格式,text/xml忽略xml头所指定编码格式而默认采用us-ascii编码,而application/xml会根据xml头指定的编码格式来编码:?application/xml and text/xml的差异application/xml and text/xml的差异
    Content-type: application/xml; charset="utf-16" {BOM}<?xml version="1.0"?>?

    XML and MIME processors会按照utf-16编码处理该文件

    ?

    例子2:

    ?webservice传输的文件

    ?application/xml and text/xml的差异application/xml and text/xml的差异
      Content-type: application/xml <?xml version='1.0'?>

      XML processors会按照utf-8编码处理该文件

      ?

      例子3:

      ?webservice传输的文件

      ?application/xml and text/xml的差异application/xml and text/xml的差异
        Content-type: application/xml <?xml version='1.0' encoding="ISO-10646-UCS-4"?>

        ?XML processors会按照UCS-4编码处理该文件
        ?

        例子4:

        ?webservice传输的文件

        ?application/xml and text/xml的差异application/xml and text/xml的差异
          Content-type: text/xml {BOM}<?xml version="1.0" encoding="utf-16"?>

          ?XML processors会按照us-ascii,而不是utf-16编码处理该文件

          ?

          参考文档:

          http://www.ietf.org/rfc/rfc2376.txt

          ?

读书人网 >XML SOAP

热点推荐