[求助] jquery读取xml
时间:2010-01-14
来源:互联网
我把该html和jquery和xml文件放在一块,源码如下:
test1.html
<html>
<head>
<meta http-equiv="Content-Type" content="application/xml">
<title>test</title>
<script type='text/javascript' src='jquery-1.3.1.min.js'></script>
<script type='text/javascript'>
jQuery().ready(function(){
$.ajax({
url:'student.xml',
dataType: 'xml',
error: function(xml){
$('#show').text('Error loading XML document'+xml);
},
success: function(xml){
$('#show').text('Success loading XML document'+xml);
}
});
})
</script>
</head>
<body>
<div id='show'></div>
</body>
</html>
student.xml:
<?xml version="1.0" encoding="UTF-8"?>
<stulist>
<student email="mailto:[email protected]" target="_blank>[email protected]">
<name>zhangsan</name>
<id>1</id>
</student>
<student email="mailto:[email protected]" target="_blank>[email protected]">
<name>lisi</name>
<id>2</id>
</student>
</stulist>
结果输出:
test jQuery().ready(function(){ $.ajax({ url:'student.xml', dataType: 'xml', error: function(xml){ $('#show').text('Error loading XML document'+xml); }, success: function(xml){ $('#show').text('Success loading XML document'+xml); /* $(xml).find("student").each(function(){ var id=$(this).children("id"); //鍙栧?璞? var id_value=$(this).children("id").text(); //鍙栨枃鏈?鎴栬
test1.html
<html>
<head>
<meta http-equiv="Content-Type" content="application/xml">
<title>test</title>
<script type='text/javascript' src='jquery-1.3.1.min.js'></script>
<script type='text/javascript'>
jQuery().ready(function(){
$.ajax({
url:'student.xml',
dataType: 'xml',
error: function(xml){
$('#show').text('Error loading XML document'+xml);
},
success: function(xml){
$('#show').text('Success loading XML document'+xml);
}
});
})
</script>
</head>
<body>
<div id='show'></div>
</body>
</html>
student.xml:
<?xml version="1.0" encoding="UTF-8"?>
<stulist>
<student email="mailto:[email protected]" target="_blank>[email protected]">
<name>zhangsan</name>
<id>1</id>
</student>
<student email="mailto:[email protected]" target="_blank>[email protected]">
<name>lisi</name>
<id>2</id>
</student>
</stulist>
结果输出:
test jQuery().ready(function(){ $.ajax({ url:'student.xml', dataType: 'xml', error: function(xml){ $('#show').text('Error loading XML document'+xml); }, success: function(xml){ $('#show').text('Success loading XML document'+xml); /* $(xml).find("student").each(function(){ var id=$(this).children("id"); //鍙栧?璞? var id_value=$(this).children("id").text(); //鍙栨枃鏈?鎴栬
[ 此帖被zchhz在2010-01-16 11:41重新编辑 ]
作者: zchhz 发布时间: 2010-01-14
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28