您的位置:首页 > 理论基础 > 计算机网络

xmlhttp.open("GET","file:///C:/Users/Administrator/Desktop/java/sample.xml",false);

2012-09-26 13:16 411 查看
<html>

<body>

<h1>W3School.com.cn Internal Note</h1>

<p><b>To:</b> <span id="to"></span><br />

<b>From:</b> <span id="from"></span><br />

<b>Message:</b> <span id="message"></span>

<script type="text/javascript">

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.open("GET","file:///C:/Users/Administrator/Desktop/java/sample.xml",false);

xmlhttp.send();

xmlDoc=xmlhttp.responseXML;

document.getElementById("to").innerHTML=

xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;

document.getElementById("from").innerHTML=

xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;

document.getElementById("message").innerHTML=

xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;

</script>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐