From 11642ba20c10ced6363d81d6e3a0239ac10dab27 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 24 Dec 2010 18:02:00 +0100 Subject: [PATCH] jQuery.parseXML extracted from ajax & added to core, needs unit testing. --- src/core.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/core.js b/src/core.js index 4c717e3b..8853e81c 100644 --- a/src/core.js +++ b/src/core.js @@ -546,6 +546,28 @@ jQuery.extend({ jQuery.error( "Invalid JSON: " + data ); } }, + + // Cross-browser xml parsing + // (xml & tmp used internally) + parseXML: function( data , xml , tmp ) { + + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + + tmp = xml.documentElement; + + if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { + jQuery.error( "Invalid XML: " + data ); + } + + return xml; + }, noop: function() {},