jQuery 获取xml数据在IE中无效的问题
前段时间用jQuery做了个小练习,获取本地的xml数据,在firefox下面测试没问题,但是在IE下面总是获取数据失败,上网找了很久也没找到是怎么回事。郁闷了很长一段时间,今天有空又把这个问题拿出来研究了下,最后终于找到原因了,把页面放到服务器去浏览就OK了。难道是权限问题?不知道怎么火狐在本地目录可以获取数据成功。对于操作xml文档要放到服务器去,要不然会没有权限。
//html
<h1>加载xml数据</h1>
<input type="button" value="加载xml数据" id="loadXml"/>
<div class="xmldata">这里显示XML数据</div>
//js
$(function(){
$("#loadXml").click(function(){
$.ajax({
type:'get',
url:'xml.xml',
dataType:"xml",
success:function(data){
$(".xmldata").empty();
$("user",data).each(function(){
var users=$(this);
var html='<div class="name">';
html+=users.find("name").text();
html+='</div>';
html+='<div class="age">';
html+=users.find("age").text();
html+='</div>';
html+='<div class="sex">';
html+=users.find("sex").text();
html+='</div>';
$(".xmldata").append($(html));
})
}
})
})
})
//xml
<?xml version="1.0" encoding="gb2312"?>
<userInfo>
<user>
<name>haohao</name>
<age>18</age>
<sex>man</sex>
</user>
<user>
<name>do
相关文档:
关于.apk 文件解压后反编译方法:[仅layout package下的xml 文件]
使用AXMLPrinter将其转换为可读的xml文件:
命令如下:
java -jar AXMLPrinter2.jar main.xml > new_main.xml
AXMLPrinter2.jar工具下载地址:http://code.google.com/p/android4me/downloads/list ......
<?xml version="1.0" standalone="yes"?>
<imgs>
<pic name="/adv_pic/1.jpg" url="http://www.baidu.com/" title="test" />
<pic name="/adv_pic/2.jpg" url="http://www.baidu.com/" title="test" />
......
public partial class Form1 : Form
{
DataSet ds = new DataSet();
public Form1()
{
......
//******************** 头文件 Markup.h *******************
// Markup.h: interface for the CMarkup class.
//
// Markup Release 11.2
// Copyright (C) 2009 First Objective Software, Inc. All rights reserved
// Go to www.firstobject.com for the latest CMarkup and EDOM documentation
// ......
对于带有表空间xmlns的xml文件的解析,用正常解析文件的方法总是失效,不起作用,无法获得元素。
下面给出两种方法解析此类文件:
1.按正常解析xml文件的方法,需要注意几点:
获取元素Element,不可使用函数:document.selectNodes("//region");
只可以先取到根元素,一级一级往下取,eg:
Element root = document.g ......