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>
评论