String to XML Document 介绍
I created a very basic function which allows you to convert XML in a string
type, into an XML Document type, which gives you the benefits of XML with
AJAX.
I’ll write up a better explanation another time, as well as submit some other
useful data conversion functions
<script type="text/javascript"> // Name: createXMLDocument // Input: String // Output: XML Document jQuery.createXMLDocument = function(string) { var browserName = navigator.appName; var doc; if (browserName == 'Microsoft Internet Explorer') { doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = 'false' doc.loadXML(string); } else { doc = (new DOMParser()).parseFromString(string, 'text/xml'); } return doc; } </script>
Usage:
<script type="text/javascript"> var text = '<message><from>me</from><to>you</to></message>'; var doc = $.createXMLDocument(text); </script>
String to XML Document 官网
http://plugins.jquery.com/project/createXMLDocument
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。