@oc来,om来  谢谢大佬帮助。
function DOM2JSON(node) {
var obj = {};
obj['tag'] = node.nodeName;
obj['children'] = [];
var child = node.children;
for (var i = 0; i < child.length; i++) {
obj['children'].push(DOM2JSON(child[i]))
}
return obj;
}