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");
}
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>
<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>
相关文章推荐
- tmp WEB 2.0中AJAX应用的详细探讨;xmlHttp.open("GET", url, true);
- filepath = XmlUtils.class.getClassLoader().getResource("users.xml").getPath();无法处理空格( )
- 异常-----web.xml文件报错 Multiple annotations found at this line: - cvc-complex-type.2.4.b: The content of element 'welcome-file-list' is not complete. One of '{"http://java.sun.c
- 异常The file cannot be validated as the XML definition "http://www.opensymphony.com/
- resin启动报错:guava-15.0.jar!/META-INF/beans.xml:5: <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"> is an unexpec
- 在java中"模拟" XMLHttpRequest
- 关于写入文件缓存时报"java.io.FileNotFoundException open failed (is a director)"错误的解决方法
- Ajax同步链接在IE 与FireFox的使用差别 open("GET",url,false)
- resin启动报错:guava-15.0.jar!/META-INF/beans.xml:5: <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"> is an unexpec
- 在java中"模拟" XMLHttpRequest
- [程序代写推荐]Exception in thread "http-apr-8080-exec-6" java.lang.OutOfMemoryError: PermGen space 解决!
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- System.Web.HttpException: The file "~/xxx//Index.cshtml" cannot be requested directly because it cal
- <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>标签再使用时报错
- java反射(1) 之class.forName(""), 类名.class, 对象.getClass()区别
- 杀毒软件影响 WinCE sysgen "EDITBIN : fatal error LNK1104: cannot open file "
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- MyEclipse 出错提示 Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- Unable to open the command file "E:\Samples\SampleApp\CC2530DB\..\.问题
- Exception in thread "http-bio-8080-exec-11" java.lang.OutOfMemoryError: PermGen space