通过 XML HTTP 加载 XML 文件
新建一个.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 文件的更多相关文章
- Spring加载properties文件的属性的值
要使用配置文件的值首先在spring.xml配置加载properties文件 <context:property-placeholder location="classpath:ife ...
- Spring加载properties文件的两种方式
在项目中如果有些参数经常需要修改,或者后期可能需要修改,那我们最好把这些参数放到properties文件中,源代码中读取properties里面的配置,这样后期只需要改动properties文件即可, ...
- js便签笔记(8)——js加载XML字符串或文件
1. 加载XML文件 方法1:ajax方式.代码如下: var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObje ...
- dom4j加载xml文件
## dom4j加载xml文件 ``` // 1. 加载xml文件 InputStream is = MyTest.class.getResourceAsStream("user.xml&q ...
- JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(12):XML配置自动扫描包,自动加载*.properties文件
一.XML和注解组合使用 前几篇的测试案例都是在Java类中配置,现在换一种使用方式,在XML中配置,使Spring IoC容器在启动之后自动去扫描配置的包路径,扫描加载指定路径下的propertie ...
- Android学习笔记_31_通过后台代码生成View对象以及动态加载XML布局文件到LinearLayout
一.布局文件part.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...
- 通过JS加载XML文件,跨浏览器兼容
引言 通过JS加载XML文件,跨多种浏览器兼容. 在Chrome中,没有load方法,需要特殊处理! 解决方案 部分代码 try //Internet Explorer { xmlDoc=new Ac ...
- 解决dom4j加载xml文件性能慢的问题
在代码中使用: 1: DocumentHelper.parseText 2: SAXReader reader = new SAXReader(); Document extdocument = re ...
- 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 ...
随机推荐
- linux内核神级list
源码: #ifndef _LINUX_LIST_H #define _LINUX_LIST_H /* * Simple doubly linked list implementation. * * S ...
- Android中对日期进行排序
最近在项目中需要将读取的数据按照时间的降序进行排序. 具体的步骤如下: 1.读取数据,存入List中 2.取出数据中的时间戳,由String转换成Date 3.使用冒泡排序对List中元素按照Date ...
- grunt构建前端自动化的开发环境
废话不多说.直奔主题. 1.安装node. 别问为什么.如果你不知道,说了你还是不知道. 别问怎么安装,自己去百度. 2.安装grunt_CLI. 安装完node,并且安装成功了,后.下载grunt_ ...
- (medium)LeetCode 220.Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array suc ...
- (转)C#picturebox控件使用
PictureBox是C#常用图片空间,本文是学习中搜集网络资料的一些整理和记录 1,PictureBox加载图片 using System.Drawing; //方式1,从图片文件载入 //下面的路 ...
- dubbo服务框架学习
====================================================================================== 1.提供注册服务.消费者可 ...
- image onclick
onclick="this.src+='?rand='+Math.random();" style="cursor: pointer; vertical-align: ...
- 程序员必备:Oracle日常维护命令
上一篇讲了Linux的日常维护命令,这篇讲讲Oracle的日常维护命令.工作中需要使用Oracle数据库的童鞋们,相信或多或少都需要对Oracle做一些基本的维护操作,例如导入导出总该有吧?( ...
- [ CodeVS冲杯之路 ] P1092
不充钱,你怎么AC? 题目:http://codevs.cn/problem/1092/ 嗯,这道题有一定难度啊,需要先用扩展欧几里得算法求出逆元,然后按照大小构一颗带边权为小时数的树 树链剖分后在树 ...
- 静态库制作.a .framework
一.静态库 .a 制作 1.新建一个Cocoa Touch Static Library 2.往里面添加文件,或者自己新建 3.添加一个Headers Phase ...