62,073
社区成员
发帖
与我相关
我的任务
分享
var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async=false;
xmldoc.load("<?xml version='1.0' encoding='utf-8'?><liuyan><people name='people'><name>111</name><content>111</content></people><people name='people'><name>222</name><content>222</content></people></liuyan>");
1、 var name=document.getElementsByTagName("people");
2、 var first=xmldoc.documentElement;
var name=first.childNodes;
3、 var name=xmldoc.selectNodes("/liuyan/people");
alert(name.length);
<script>
$(document).ready(function() {
$.ajax({
cache: false, //不保存缓存
url: 'data.xml',
dataType: 'xml',
type: 'GET',
timeout: 1000,
error: function(xml) {
alert("加载数据文件失败...");
},
success: function(xml) {
$(xml).find("taskList").each(function(i) {
var _Id = $(this).children("id");
//获取id节点的文本值;
var id = _Id.text();
})
}
});
})
</script>