ffffng/app/bower_components/jquery/src/ajax/parseXML.js

31 lines
559 B
JavaScript
Raw Normal View History

2017-05-13 13:25:33 +02:00
define( [
2014-05-12 20:08:19 +02:00
"../core"
], function( jQuery ) {
2017-05-13 13:25:33 +02:00
"use strict";
2014-05-12 20:08:19 +02:00
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
2017-05-13 13:25:33 +02:00
var xml;
2014-05-12 20:08:19 +02:00
if ( !data || typeof data !== "string" ) {
return null;
}
2017-05-13 13:25:33 +02:00
// Support: IE 9 - 11 only
// IE throws on parseFromString with invalid input.
2014-05-12 20:08:19 +02:00
try {
2017-05-13 13:25:33 +02:00
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
2014-05-12 20:08:19 +02:00
} catch ( e ) {
xml = undefined;
}
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data );
}
return xml;
};
return jQuery.parseXML;
2017-05-13 13:25:33 +02:00
} );