新建一个.aspx文件

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="02-通过 XML HTTP 加载 XML 文件.aspx.cs"
     Inherits="_02_通过_XML_HTTP_加载_XML_文件" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
     <title></title>
     <script type="text/javascript">
         var xmlhttp;
         function loadXMLDoc(url)
         {
             xmlhttp = null;
             if (window.XMLHttpRequest)
             {// code for IE7, Firefox, Opera, etc.
                 xmlhttp = new XMLHttpRequest();
             }
             else if (window.ActiveXObject)
             {// code for IE6, IE5
                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
             }
             if (xmlhttp != null)
             {
                 xmlhttp.onreadystatechange = state_Change;
                 xmlhttp.open("GET", url, true);
                 xmlhttp.send(null);
             }
             else
             {
                 alert("Your browser does not support XMLHTTP.");
             }
         }

         function state_Change()
         {
             if (xmlhttp.readyState == 4)
             {// 4 = "loaded"
                 if (xmlhttp.status == 200)
                 {// 200 = "OK"
                     document.getElementById('A1').innerHTML = xmlhttp.status;
                     document.getElementById('A2').innerHTML = xmlhttp.statusText;
                     document.getElementById('A3').innerHTML = xmlhttp.responseText;
                 }
                 else
                 {
                     alert("Problem retrieving XML data:" + xmlhttp.statusText);
                 }
             }
         }
     </script>
 </head>
 <body>
     <h2>
         Using the HttpRequest Object</h2>
     <p>
         <b>Status:</b> <span id="A1"></span>
     </p>
     <p>
         <b>Status text:</b> <span id="A2"></span>
     </p>
     <p>
         <b>Response:</b>
         <br />
         <span id="A3"></span>
     </p>
     <button onclick="loadXMLDoc('note.xml')">
         Get XML</button>
 </body>
 </html>

note.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
    <to>George</to>
    <from>John</from>
    <heading>Reminder</heading>
    <body>Don't forget the meeting!</body>
</note> 

通过 XML HTTP 加载 XML 文件的更多相关文章

  1. Spring加载properties文件的属性的值

    要使用配置文件的值首先在spring.xml配置加载properties文件 <context:property-placeholder location="classpath:ife ...

  2. Spring加载properties文件的两种方式

    在项目中如果有些参数经常需要修改,或者后期可能需要修改,那我们最好把这些参数放到properties文件中,源代码中读取properties里面的配置,这样后期只需要改动properties文件即可, ...

  3. js便签笔记(8)——js加载XML字符串或文件

    1. 加载XML文件 方法1:ajax方式.代码如下: var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObje ...

  4. dom4j加载xml文件

    ## dom4j加载xml文件 ``` // 1. 加载xml文件 InputStream is = MyTest.class.getResourceAsStream("user.xml&q ...

  5. JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(12):XML配置自动扫描包,自动加载*.properties文件

    一.XML和注解组合使用 前几篇的测试案例都是在Java类中配置,现在换一种使用方式,在XML中配置,使Spring IoC容器在启动之后自动去扫描配置的包路径,扫描加载指定路径下的propertie ...

  6. Android学习笔记_31_通过后台代码生成View对象以及动态加载XML布局文件到LinearLayout

    一.布局文件part.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  7. 通过JS加载XML文件,跨浏览器兼容

    引言 通过JS加载XML文件,跨多种浏览器兼容. 在Chrome中,没有load方法,需要特殊处理! 解决方案 部分代码 try //Internet Explorer { xmlDoc=new Ac ...

  8. 解决dom4j加载xml文件性能慢的问题

    在代码中使用: 1: DocumentHelper.parseText 2: SAXReader reader = new SAXReader(); Document extdocument = re ...

  9. Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)

    今天配置Spring的xml出现了错误 Multiple annotations found at this line: - schema_reference.4: Failed to read sc ...

随机推荐

  1. Jquery插件收藏

    1.带小图标的多级菜单导航 演示地址:http://js.itivy.com/memu/sample.html 下载地址:http://js.itivy.com/?p=100 效果图:  推荐一个自己 ...

  2. java中的xml与实体类之间的映射

    实体类: package xml; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class User ...

  3. 用SPCOMM 在 Delphi中实现串口通讯 转

      用Delphi 实现串口通讯,常用的几种方法为:使用控件如MSCOMM和SPCOMM,使用API函数或者在Delphi 中调用其它串口通讯程序.利用API编写串口通信程序较为复杂,需要掌握大量通信 ...

  4. PL/SQL Developer使用技巧、快捷键

    1.类SQL PLUS窗口:File->New->Command Window,这个类似于oracle的客户端工具sql plus,但比它好用多了. 2.设置关键字自动大写:Tools-& ...

  5. Xpath定位大全

    selenium使用Xpath定位之完整篇   其中有一片文章提到了xpath元素定位,但是该文章中有些并不能适应一些特殊与个性化的场景.在文本中提供xpath元素的定位终极篇,你一定能在这里找到你需 ...

  6. 【转】Bash脚本实现批量作业并行化

    首先附上自己常用的代码 ---------------------------------------------------------------------------------------- ...

  7. Esfog_UnityShader教程_漫反射DiffuseReflection

    这篇是系列教程的第三篇,最近工作比较紧,所以这个周六周日就自觉去加了刚回来就打开电脑补上这篇,这个系列的教程我会尽量至少保证一周写一篇的.如果大家看过我的上一篇教程<Esfog_UnitySha ...

  8. iis实现类似tomcat ip:port直接访问站点

    先配置host: 建站点: iis配置文件地址:C:\Windows\System32\inetsrv\config\applicationHost.config(于tomcat中的web.xml类似 ...

  9. 【LeetCode】18. 4Sum

    题目: 思路:这题和15题很像,外层再加一个循环稍作修改即可 public class Solution { public List<List<Integer>> fourSu ...

  10. 跟我学 NHibernate (一)

    NHibernate 是一个强大的 ORM 框架,本博文主要就 NHibernate 的使用方法及语法做一些简单的介绍.  1.NHibernate 语法   新建一个类,命名为: QueryCrit ...