All pastes #1202455 Raw Edit

fearphage

public javascript v1 · immutable
#1202455 ·published 2008-09-14 11:01 UTC
rendered paste body
function parseXML(str) {  var xmlDoc;  str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><x xmlns="http://www.w3.org/1999/xhtml">' + str + '</x>';  // chrome, opera, mozilla, safari  try {    xmlDoc = (new  DOMParser()).parseFromString(str, 'text/xml')  } catch (e) {    try {      xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); xmlDoc.async = 'false'; xmlDoc.loadXML(str);    } catch (e) {       xmlDoc = false;    }  }  debug('document.adoptNode: ' + document.adoptNode + '\ndocument.importNode = ' + document.importNode);  xmlDoc = (document.adoptNode            ? document.adoptNode(xmlDoc.documentElement)           : (document.importNode              ? document.importNode(xmlDoc.documentElement, true)             : xmlDoc.documentElement             )           );  return xmlDoc;}