var text2xml = function(s) { 
  var x, ie = /msie/i.test(navigator.userAgent); 
  try { 
    var p = ie? new ActiveXObject("Microsoft.XMLDOM") : new DOMParser(); 
    p.async = false; 
  } catch(e) {
    throw new Error("XML Parser could not be instantiated")
  }; 
  try { 
    if (ie) x = p.loadXML(s)? p : false; 
    else x = p.parseFromString(s, "text/xml"); 
  } catch(e) {
    throw new Error("Error parsing XML string")
  }; 
  return x; 
};
