application / xml and text / xml difference

2011-10-13  来源:本站原创  分类:Internet  人气:81 

application / xml and text / xml difference
Often see the xml mentioned "application / xml" and "text / xml" two types, both function exactly the same, only difference is the encoding format, text / xml ignore xml header encoding format specified by the default use of us -ascii encoding, and application / xml xml header according to the specified encoding format to encode:

XML has two MIME types, application / xml and text / xml. These are often used interchangeably, but there is a subtle difference which is why application / xml is generally recommended over the latter.

Let me explain why: according to the standard, text / *-MIME types have a us-ascii character set unless otherwise specified in the HTTP headers. This effectively means that any encoding defined in the XML prolog (eg <? Xml version = " 1.0 "encoding =" UTF-8 "?>) is ignored. This is of course not the expected and desired behaviour.

To further complicate matters, most / all browser implementations actually implement nonstandard behaviour for text / xml because they process the encoding as if it were application / xml.

So, text / * has encoding issues, and is not implemented by browsers in a standards-compliant manner, which is why using application / * is recommended.
text / xml and application / xml character set encoding

Keywords: text / xml application / xml

For Webservice application, we usually use UTF-8 transport network, but there are also transmitted by GBK and GB2312 situation, but the code in our Webservice, in fact, is not concerned about the specific transmission coding, because, according to RFC2376 definition, Webservice engine (axis, cxf, jaxws ..) according to the ContentType of the file transfer part of the definition and the XML declaration encoding will automatically transfer over the network content (string) into unicode (jvm run-time string are there as unicode). The following is a description of RFC2376:

相关文章
  • application / xml and text / xml difference 2011-10-13

    application / xml and text / xml difference Often see the xml mentioned "application / xml" and "text / xml" two types, both function exactly the same, only difference is the encoding format, text / xml ignore xml header encoding forma

  • application/xml and text/xml的区别 2012-11-30

    经常看到有关xml时提到"application/xml" 和 "text/xml"两种类型, 二者功能一模一样,唯一的区别就是编码格式,text/xml忽略xml头所指定编码格式而默认采用us-ascii编码,而application/xml会根据xml头指定的编码格式来编码: XML has two MIME types,application/xml and text/xml . These are often used interchangeably, bu

  • XML or text declaration not at start of entity Abnormal 2010-12-17

    Today, when doing XML parsing, always giving me reports XML Parsing Error: XML or text declaration not at start of entity Error, then check the next talk about android in the mean time to resolve the problem xml file format. The forefront of the file

  • flex action xml file. and the difference .. 2010-04-16

    xml file is as follows, treeMsg.xml: <?xml version="1.0" encoding="UTF-8"?> <pdml> <field showname="aa"> <field showname="ss"/> <field showname="dd"/> <field showname="

  • Xiang Jie Struts configuration file, web.xml and struts-cofig.xml, as well as the struts-cofig.xml in the role of the various labels 2010-04-19

    Struts applications use two XML-based configuration files to configure, respectively web.xml and struts-cofig.xml file. Web.xml file is the configuration for all web applications, while the struts-config.xml file is struts-specific configuration file

  • Javascript to read XML String or XML File 2009-09-30

    function listAllStates() { var xmlDoc; var xmlString = '<states><state>wei</state></states>'; // Mozilla and Netscape browsers if (document.implementation.createDocument) { var parser = new DOMParser() xmlDoc = parser.parseFromStri

  • xml soap and xml with post delivery problems 2010-04-02

    First of all, someone has made a library http://sourceforge.net/projects/ksoap2/ http://code.google.com/p/ksoap2-android/wiki/SourceCodeHosting?tm=4 If you want to write your own 1. Pass a simple html and data issues HttpClient httpclient = new Defau

  • XML DTD and XML Schema Comparison and analysis of technology 2010-12-09

    http://www.ibm.com/developerworks/cn/xml/x-sd/ Introduction XML DTD (XML Document Type Definition) XML technology in recent years the most widely used as a model. However, the XML DTD can not fully meet the requirements of the automated processing of

  • JS解析XML文件和XML字符串详解 2014-08-06

    这篇文章主要介绍了JS解析XML文件和XML字符串详解,推荐给大家,有需要的小伙伴可以参考下. JS解析XML文件 <script type='text/javascript'> loadXML = function(xmlFile){ var xmlDoc=null; //判断浏览器的类型 //支持IE浏览器 if(!window.DOMParser && window.ActiveXObject){ var xmlDomVersions = ['MSXML.2.DOMDoc

  • XML Schema test XML document structure 2010-04-14

    1. XML Schema Description XML Schema (also known as XML Schema Definition), is used to test the structure of XML documents is the DTD file replacement. As the XML structure of XML Schema itself, so it is easy to grasp and expand. Click here for detai

  • Fu-android URL address from the network to read XML file using XML Pull parsing 2010-12-03

    To resolve the network file: http://www.jinghua.cn/iphone/xml/bj.xml Code Analysis /** * Read from the network address URL XML File Pull parsing XML--- Resolution jinghua2.xml * @param xmlUrlPath xml Network address * @return AFO * @throws Exception

  • XML strings and XML DOCUMENT summary of the mutual conversion 2011-05-03

    Reprinted from: http://blogold.chinaunix.net/u1/55983/showart_2104565.html Only to find areas Doing a general XML data exchange process, I prefer to pass XML string, rather than the format of the XML Document. This involves the XML string and Xml Doc

  • jquery解析XML字符串和XML文件的方法说明 2014-01-27

    本篇文章主要是对jquery解析XML字符串和XML文件的方法进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助 1.读取XML字符串:例如: $(document).ready(function(){ var xml = "<xml><root><record><name>liubl</name></record><record><name>chencp</name</record

  • php xml留言板 xml存储数据的简单例子 2014-11-05

    php xml留言板 xml存储数据的简单例子 php操作xml的简单留言板,带分页,仅供参考 类文件 : _class.xmldb.inc.php <?php class xmldb extends DOMDocument{ var $xmldb; public function __construct($xmldbname){ $this->xmldb=$xmldbname; if(!file_exists($this->xmldb)){ $initxmldb = "<

  • js解析xml字符串和xml文档实现原理及代码(针对ie与火狐) 2014-11-16

    分别针对ie和火狐分别作了对xml文档和xml字符串的解析,考虑到了浏览器的兼容性,至于在ajax环境下解析xml,其实原理是一样的,只不过放在了ajax里,还是要对返回的xml进行解析,感兴趣的朋友可以了解下,或许对你学习js解析xml有所帮助 分别针对ie和火狐分别作了对xml文档和xml字符串的解析,所有代码都注释掉了,想看哪部分功能,去掉注释就可以了. 至于在ajax环境下解析xml,其实原理是一样的,只不过放在了ajax里,还是要对返回的xml进行解析. <!DOCTYPE HTML

  • Java中读取XML文件,生成XML格式的字符串并解析这个字符串 2011-09-29

    由于最近要用的是XML格式的字符串,而不用写到文件中,所以对原始代码进行了修改如下: 要读的xml文件 <?xml version="1.0" encoding="GB2312"?> <学生花名册> <学生 性别 = "男"> <姓名>李华</姓名> <年龄>14</年龄> </学生> <学生 性别 = "男"> <

  • 关于XML字符串和XML Document之间的转换 2013-03-12

    转自http://yangfei520.blog.51cto.com/1041581/382977 在web项目中,XML作为一种重要的数据存储和传输介质,被广泛使用.XML文件,XML字符串和XML Document对象是XML存在的三种形式,XML文件无需多言,和普通的文本并无二致:倒是在做一般的XML数据交换过程中,经常要使用XML字符串和XML Document对象,因此在这两种形式之间进行转化成为了使用XML的必备技术.在所有操控XML的技术中,都提供了这两种形式XML之间的转换方法.

  • java XML字符串和XML DOCUMENT的相互转换 2013-09-11

    在做一般的XML数据交换过程中,我更乐意传递XML字符串,而不是格式化的XML Document.这就涉及到XML字符串和Xml Document的转换问题,说白了这是个很简单的问题,本文就各种XML解析器分别列举如下,以方便自己今后查阅. 一.使用最原始的javax.xml.parsers,标准的jdk api // 字符串转XML String xmlStr = "......"; StringReader sr = new StringReader(xmlStr); InputS

  • Java by XML Schema validation XML 2010-03-29

    Java by XML Schema validation XML XML validation in the XML processing is very common, if there is no effective way to verify the legitimacy of XML, often lead to many problems. XML validation by XML Schema (XSD) or DTD file to verify the syntax spec

  • xml schema validation XML legitimacy 2010-04-01

    xml schema validation XML legitimacy (examples) Change: the original from http://lavasoft.blog.51cto.com/62575/97597 XML validation is very common in XML processing, if there is no effective way to verify the legitimacy of XML, often lead to many pro