JAVASCRIPT 7
ParseXML.js Guest on 8th April 2021 06:04:09 AM
  1. define([
  2.       "../core"
  3. ], function( jQuery ) {
  4.  
  5. // Cross-browser xml parsing
  6. jQuery.parseXML = function( data ) {
  7.       var xml, tmp;
  8.       if ( !data || typeof data !== "string" ) {
  9.             return null;
  10.       }
  11.  
  12.       // Support: IE9
  13.       try {
  14.             tmp = new DOMParser();
  15.             xml = tmp.parseFromString( data, "text/xml" );
  16.       } catch ( e ) {
  17.             xml = undefined;
  18.       }
  19.  
  20.       if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  21.             jQuery.error( "Invalid XML: " + data );
  22.       }
  23.       return xml;
  24. };
  25.  
  26. return jQuery.parseXML;
  27.  
  28. });

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.