2 * jQuery xmlDOM Plugin v1.0
3 * http://outwestmedia.com/jquery-plugins/xmldom/
8 * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC.
9 * Dual licensed under the MIT and GPL licenses.
10 * http://docs.jquery.com/License
13 // IE DOMParser wrapper
14 if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
15 DOMParser = function() { };
16 DOMParser.prototype.parseFromString = function( xmlString ) {
17 var doc = new ActiveXObject('Microsoft.XMLDOM');
19 doc.loadXML( xmlString );
24 $.xmlDOM = function(xml, onErrorFn) {
26 var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
27 if ( $.isXMLDoc( xmlDoc ) ) {
28 var err = $('parsererror', xmlDoc);
29 if ( err.length == 1 ) {
30 throw('Error: ' + $(xmlDoc).text() );
33 throw('Unable to parse XML');
36 var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
37 if ( $.isFunction( onErrorFn ) ) {
40 $(document).trigger('xmlParseError', [ msg ]);