package.src.core.parseXML.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jquery Show documentation
Show all versions of jquery Show documentation
JavaScript library for DOM operations
The newest version!
define( [
"../core"
], function( jQuery ) {
"use strict";
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
var xml, parserErrorElem;
if ( !data || typeof data !== "string" ) {
return null;
}
// Support: IE 9 - 11 only
// IE throws on parseFromString with invalid input.
try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
} catch ( e ) {}
parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
if ( !xml || parserErrorElem ) {
jQuery.error( "Invalid XML: " + (
parserErrorElem ?
jQuery.map( parserErrorElem.childNodes, function( el ) {
return el.textContent;
} ).join( "\n" ) :
data
) );
}
return xml;
};
return jQuery.parseXML;
} );