<html>
<head>
<title>AjaxTest</title>
<script>
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
try
{
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "data.xml", true);
xmlHttp.send(null);
}
catch(exception)
{
alert("xmlHttp Fail");
}
}
function handleStateChange()
{
if(xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200 || xmlHttp.status == 0)
{
var root = xmlHttp.responseXML.documentElement;
try
{
var info = root.getElementsByTagName("info")[0];
alert(info.getAttribute('type'));
}
catch(exception)
{
alert("The node is not exist");
}
}
}
}
</script>
</head>
<body>
<div>
<input type="button" value="AjaxTest" onclick="startRequest();" />
</div>
</body>
</html> XML code <?xml version="1.0" encoding="GB2312"?>
<root>
<info type="student"></info>
</root>

  

用 AJAX 读取xml 节点属性值的更多相关文章

  1. C# 读取XML节点属性值

    xml文件格式如下: <?xml version="1.0" encoding="UTF-8" ?> <Product type=" ...

  2. js 解析XML 在Edge浏览器下面 无法准确读到节点属性值

    js 解析XML 在Edge浏览器下面 无法准确读到节点属性值 Dom.documentElement.childNodes[j].attributes[2]  这个是大众写法 在win10的edge ...

  3. C#读取xml节点数据方法小结

    本文实例总结了C#读取xml节点数据的方法.分享给大家供大家参考.具体如下: 第一种: 使用XPath XML的路径我配置在web.config 的appSettings节点下 <appSett ...

  4. 详解SimpleXML添加_修改_删除_遍历XML节点属性

    SimpleXML概述 要处理XML 文件,有两种传统的处理思路:SAX 和DOM.SAX 基于事件触发机制,对XML 文件进行一次扫描,完成要进行的处理:DOM 则将整个XML 文件构造为一棵DOM ...

  5. jquery 取子节点及当前节点属性值

    分享下jquery取子节点及当前节点属性值的方法. <li class="menulink"><a href="#" rel="ex ...

  6. flash读取XML节点内容以及节点属性

    原文地址:http://hi.baidu.com/yqzdm/item/f95fd9d24679d916d90e44c9 一.xml的写法: 这里的xml只是在有限范围内的了解,限于写一些简单的用于f ...

  7. 递归遍历XML节点属性和属性值

    public static XmlDocument FileMergedIntoXML(string strXmlPathPublic) { string strXmlPathPublic = str ...

  8. java对xml节点属性的增删改查

    学习本文之前请先看我的另一篇文章JAVA对XML节点的操作可以对XML操作有更好的了解. package vastsum; import java.io.File; import java.io.Fi ...

  9. Dom4j使用Xpath语法读取xml节点

    我们可以使用Xpath的语法来轻易的读取xml的某个节点[类似于jQuery的选择器]: 使用Xpath语法需要添加新的jaxen-1.1-beta-7.rar 这个jar包 dom4j完整jar包我 ...

随机推荐

  1. 新浪sae上安装原生wordpress4.1

    1. 加入/改动wp-config.php文件 <?php /** * WordPress 基础配置文件. * * 本文件包括下面配置选项: MySQL 设置.数据库表名前缀. * 密匙.Wor ...

  2. kafka集群原理介绍

    目录 kafka集群原理介绍 (一)基础理论 二.配置文件 三.错误处理 kafka集群原理介绍 @(博客文章)[kafka|大数据] 本系统文章共三篇,分别为 1.kafka集群原理介绍了以下几个方 ...

  3. [Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe

    The network may be unreliable and loading data may take time. Thus it is important to give the user ...

  4. python爬虫(一)抓取 色影无忌图片

    原文地址: http://www.30daydo.com/article/56 由于平时爱好摄影.所以喜欢看看色影无忌论坛的获奖摄影作品,所以写了个小script用来抓取上面的获奖图片,亲自測试能够使 ...

  5. 数学之路-python计算实战(7)-机器视觉-图像产生加性零均值高斯噪声

    图像产生加性零均值高斯噪声.在灰度图上加上噪声,加上噪声的方式是每一个点的灰度值加上一个噪声值.噪声值的产生方式为Box-Muller算法生成高斯噪声. 在计算机模拟中,常常须要生成正态分布的数值.最 ...

  6. Android学习笔记:Home Screen Widgets(2):关于Widget

    通过widget定义,我们在widget列表中看到了我们的TestWidget.当我们拖拽widget到主页时,假设在appwidet-provider中定义了android:configure的ja ...

  7. Velocity浅析及与Jsp、Freemarker对比 分类: B1_JAVA 2014-07-21 09:14 637人阅读 评论(0) 收藏

    转载自:http://www.cnblogs.com/petermsdn/archive/2011/05/06/2039178.html Velocity 是一个基于java 的模板引擎(templa ...

  8. js,jquery遍历数组,对象

    each的用法  1.数组中的each 复制代码 var arr = [ "one", "two", "three", "four ...

  9. ios开发日期的NSDate,NSCalendar分类

    #import <Foundation/Foundation.h> @interface NSDate (XMGExtension) /** */ // @property (nonato ...

  10. pthread_join/pthread_exit的使用方法解析

    官方说法: 函数pthread_join用来等待一个线程的结束.函数原型为: extern int pthread_join __P ((pthread_t __th, void **__thread ...