新建一个.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. struts2 使用注解方式配置

    1.导入convention 包 2.java: package com.struts.base.hello; import java.io.IOException; import java.io.P ...

  2. [ActionScript 3.0] AS3.0 本机鼠标指针

    Flash Player 10.2添加了内置的本机鼠标指针(native mouse cursor)支持,虽然在之前的版本里我们可以侦听MouseEvent事件来模拟鼠标指针,但是在有了原生的本机鼠标 ...

  3. 在MS CRM 4.0中引用JS文件

    引用: http://blog.csdn.net/qzw4549689/article/details/6027987 1.编写好JS代码,在ISV目录下新建一个目录javascripts,将JS文件 ...

  4. iBeacons 资源汇总

    从淘宝上购买了iBeacons的开发模块,便开始要熟悉这个技术了. 先来说一下什么是iBeacons iBeacons是苹果在2013年WWDC上推出一项基于蓝牙4.0(Bluetooth LE | ...

  5. (转)使用Ping获得局域网机器信息

    实际编程中会遇到查找局域网机器的情况,这个时候ping命令对我们帮助比较大,一般来说,都是在命令行中输入“ping XXX -t”,下面的方法是在C#编码中使用Ping. 原文地址:http://zh ...

  6. junit适配器模式应用

    适配器模式 定义: 将一个类的接口转换成客户希望的另外一个接口.Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作: 构成: 目标抽象角色(Target):定义客户要用的特定领 ...

  7. Kendo UI - Class 基类定义

    在 kendo 中,使用原型继承机制,Class 是 Kendo 中的基类,定义了函数 extend 用来派生其它类. function Class() {} Class.extend = funct ...

  8. vc 取windows系统信息 版本 cpu信息 内存信息 ie版本信息 office版本

    头文件: /*! Copyright (C) *---------------------------------------------------------------------------- ...

  9. Java将Unix时间戳转换成指定格式日期

    public String TimeStamp2Date(String timestampString, String formats){     Long timestamp = Long.pars ...

  10. EasyUI datagrid组件绑定有转义字符的json数据出错

    最近项目中一个页面的datagrid出现了莫名其妙的问题, 首先是分页数据的第二页和第三页不能展示,过了一天后第一页也出不来了, 默认首页不出来导致后续分页处理无法进行, 整个数据都不出来了,最后只能 ...