62,272
社区成员
发帖
与我相关
我的任务
分享
<script>
$(document).ready(function(){
$.ajax({
url: 'q.xml',
dataType: 'xml',
type: 'GET',
timeout: 1000,
error: function(xml){
alert("loading xml error");
},
success: function(xml){
$(xml).find("student").each(function(i){
var oId = $(this).children("id");
//获取id节点的文本值;
var IdValue = oId.text();
var oEmail = $(this).attr('email');
$("<li></li>").html(IdValue).appendTo("ol");
$("<li></li>").html(oEmail).appendTo("ol");
})
}
});
})
</script>
<?xml version="1.0" encoding="utf-8" ?>
<stulist>
<student email="1@1.com">
<name>
zhangsan
</name>
<id>
1
</id>
</student>
<student email="2@2.com">
<name>
list
</name>
<id>
2
</id>
</student>
</stulist>
