Docs: Update remaining HTTP URLs to HTTPS
[jquery.git] / src / core / parseXML.js
blobfa1b94c00d4d607fd283ddad08fa78ecd07398dc
1 import { jQuery } from "../core.js";
3 // Cross-browser xml parsing
4 jQuery.parseXML = function( data ) {
5         var xml, parserErrorElem;
6         if ( !data || typeof data !== "string" ) {
7                 return null;
8         }
10         // Support: IE 9 - 11+
11         // IE throws on parseFromString with invalid input.
12         try {
13                 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
14         } catch ( e ) {}
16         parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
17         if ( !xml || parserErrorElem ) {
18                 jQuery.error( "Invalid XML: " + (
19                         parserErrorElem ?
20                                 jQuery.map( parserErrorElem.childNodes, function( el ) {
21                                         return el.textContent;
22                                 } ).join( "\n" ) :
23                                 data
24                 ) );
25         }
26         return xml;