1、xml结构:
2、jquery 解析方法:
$(xml).find("RightMenuItems").each(function () {
this.data = Traversal($(this).children());
});
var Traversal = function (nodes) {
var itemList = new Array();
$.each(nodes, function () {
var entity = new RightMenuEntity();
var obj = $(this);
entity.Code = obj[0].getAttribute("Code");
entity.Name = obj[0].getAttribute("Name");
entity.GroupCode = obj[0].getAttribute("GroupCode");
entity.GroupName = obj[0].getAttribute("GroupName");
if (obj[0].hasChildNodes()) entity.ChildItems = Traversal(obj.children());
itemList.push(entity);
});
return itemList;
};