js读取xml

function loadXML(xmlFile) {
	var xmlDoc;
	try //Internet Explorer
	{
	 	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	 	xmlDoc.async=false;
	 	xmlDoc.load(xmlFile);
	}
	catch(e)
	{
	 	try //Firefox, Mozilla, Opera, etc.
	 	{
	  		xmlDoc=document.implementation.createDocument("","",null);
	  		xmlDoc.async=false;
	  		xmlDoc.load(xmlFile);
	 	}
	 	catch(e)
	 	{
	  		try //Google Chrome
	  		{
	   			var xmlhttp = new window.XMLHttpRequest();
	   			xmlhttp.open("GET",xmlFile,false);
	   			xmlhttp.send(null);
	  			xmlDoc = xmlhttp.responseXML.documentElement;
	  		}
	  		catch(e)
	  		{
	   			error=e.message;
	  		}
	 	}
	}
	return xmlDoc;
}

你可能感兴趣的:(读取xml)