<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> two load XML document JS code </title>
<script language= "Web Effects" >
function Loadxml (filename) {
@mrthink. Net
var xmldoc = null;
if (window.activexobject) {//write to IE Department
xmldoc = new ActiveXObject ("Microsoft.XMLDOM");
Xmldoc.async = false;//This sentence, otherwise the IE will report that the data required to complete the operation is not available
Xmldoc.loadxml (filename);//This is used to load an XML string.
Xmldoc.load (filename);//If you are using an XML file.
}
Else
if (document.implementation && document.implementation.createdocument) {//webkit,geckos,op kernel
var xmlhttp = new Window.xmlhttprequest ();
Xmlhttp.open ("Get", filename, false);//type, filename, cache
Xmlhttp.send (NULL);
xmldoc = Xmlhttp.responsexml;
}
else {
xmldoc = null;
}
return xmldoc;
}
Method Two
var xmldoc;
Try{//ie
Create an empty Microsoft XML Document Object
Xmldoc=new ActiveXObject ("Microsoft.XMLDOM");
}catch (e) {
Try{//ff
To create an empty XML Document object
Xmldoc=document.implementation.createdocument ("", "", null);
}catch (e) {
alert (e.message);
}
}
try{
Turns off asynchronous loading, which ensures that the parser does not continue to execute scripts until the document is fully loaded
Xmldoc.async=false;
Load XML document
Xmldoc.load (Xml_file);
}catch (e) {
alert (e.message);
return false;
}
return xmldoc;
</script>
<body>
In principle, fully compatible loading XML functions. After my test are: ie6/7/8,ff (geckos), Chrome (WebKit), opera, did not install Safira, but her and chrome-like core, should be no problem.
</body>