<script>
var xmlDoc= new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async=false;
xmlDoc.loadXML(src);//src为xml文件的路径
alert(xmlDoc.xml);
</script>
var xmlDoc= new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async=false;
xmlDoc.loadXML(src);//src为xml文件的路径
alert(xmlDoc.xml);
</script>
xmlDoc.loadXML(src);//src为xml文件的路径
=====>
xmlDoc.load(src);//src为xml文件的路径
<html>
<head>
<title>Ajax Hello World</title>
<script type="text/javascript">
var xmlHttp;function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}function startRequest(){
createXMLHttpRequest();
try{
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "data.xml", true);
xmlHttp.send(null);
}catch(exception){
alert("eeee!");
}
}function handleStateChange(){
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200 || xmlHttp.status == 0){ var xmlDOM = xmlHttp.responseXML; var root = xmlDOM.documentElement;
try
{ var info = root.getElementsByTagName('info'); alert("responseXML's value: " + info[0].firstChild.data);
}catch(exception)
{
alert("The source is not exist!");
}
}
}
}
</script>
</head>
<body>
<div>
<input type="button" value="return ajax responseXML's value"
onclick="startRequest();" />
</div>
</body>
</html>xml文件:
<?xml version="1.0" encoding="GB2312" ?>
<root>
<info>hello world!</info>
</root>
nodeName
xml dom的标准属性都可以访问