tree = new dTree('tree');//创建一个对象.
$.ajax({
<span style="white-space: pre;"> </span>url:'NodesPrint',
type:'post', //数据发送方式
dataType:($.browser.msie)? "text" : "xml", //接受数据格式
error:function(json){ alert( "not lived!"); },
async: false ,
success: function(data){
var xml;
if(typeof data == "string"){
xml = new ActiveXObject("Microsoft.XMLDOM"); //ie6,ie7需要,firefox,ie8不需要
xml.async = false;
xml.loadXML(data);
}else{
xml = data;
}
$(xml).find("node").each(function(){
var nodeId=$(this).attr("nodeId");
var parentId=$(this).attr("parentId");
var hrefAddress=$(this).attr("hrefAddress");
var nodeName=$(this).text();
//alert(nodeId+" "+parentId+" "+hrefAddress+" "+nodeName);
tree.add(nodeId,parentId,nodeName,hrefAddress,"","mainarea","","",false);
});
}
});
document.write(tree);
JQuery 遍历 XML
最新推荐文章于 2023-01-05 19:18:42 发布