新建一个.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. 查看Oracle的SID用户名等信息

    源地址:http://zhidao.baidu.com/question/681563406501077052.html 用sysdba身份登录 比如 conn /as  sysdba 匿名管理员登陆 ...

  2. 94、EventBus框架 ---- 转载

    EventBus使用之基础 http://blog.csdn.net/yanbober/article/details/45667363 EventBus框架库代码走读  http://blog.cs ...

  3. C语言中fseek函数

    C语言fseek()函数:用来设定文件的当前读写位置 头文件: #include <stdio.h> 定义函数: int fseek(FILE * stream, long offset, ...

  4. 第十章 Vim程序编辑器学习

    1.Vim是进阶版的vi,vim不但可以用不同颜色显示文字内容,还能进行诸如shell script,C program等程序编辑功能. 区别:vi是老师的字处理器,不过功能已经很齐全,但还是有可以进 ...

  5. rman异机恢复(RAC双节点恢复到单节点)

    一.数据库全备 RUN {ALLOCATE CHANNEL ch00 DEVICE TYPE disk;ALLOCATE CHANNEL ch01 DEVICE TYPE disk;backup as ...

  6. sqlite报错OutOfMemory

    如 java.sql.SQLException: out of memory at org.sqlite.DB.throwex(DB.java:252) at org.sqlite.NestedDB. ...

  7. Antlr学习

    参加工作之后,接触DSL领域语言,了解了编译原理. 比如Hibernate.Hive等的HQL都是基于antlr编写的 所以,如果想自己实现一套DSL语言,我们可以基于antlr做词法分析与语法分析 ...

  8. Oracle Profile 使用详解--zhuanzai

    一.目的: Oracle系统中的profile可以用来对用户所能使用的数据库资源进行限制,使用Create Profile命令创建一个Profile,用它来实现对数据库资源的限制使用,如果把该prof ...

  9. [分享·JavaScript]提取Table中的内容到XML对象

    在公司工作的时候,经常需要在前端进行这样的数据提取的操作.而之前的针对每个页面中的Table都重新写原生的JS代码效率太低,且不方便aspx对XML进行处理. 所以,在今天抽时间写了这么一个JS类,见 ...

  10. 1、程序启动原理和UIApplication【转】

    一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序. (2)每一个应用都有自己的UIApplica ...