请把下面的xml格式改写能json格式:
<?xml version="1.0"?>
<container>
<node id="0" text="技术部">
<node id="4" text="研发组">
<node id="3" text="程序员" />
<node id="5" text="测试员" />
</node>
<node id="2" text="实施组" />
</node>
<node id="1111" text="销售部" />
</container>
<?xml version="1.0"?>
<container>
<node id="0" text="技术部">
<node id="4" text="研发组">
<node id="3" text="程序员" />
<node id="5" text="测试员" />
</node>
<node id="2" text="实施组" />
</node>
<node id="1111" text="销售部" />
</container>
"3", "text": "程序员" }, {"id": "5", "text": "测试员" } ], "text": "研发组" }, {
"id": "2", "text": "实施组" } ], "text": "技术部" }, {"id": "1111", "text": "销
售部" } ] }}
[
{ id: 0, text: 技术部, children:
[
{ id: 4, text: 研发组, children:
[
{ id: 3, text: 程序员, children: null },
{ id: 5, text: 测试员, children: null }
]
},
{ id: 2, text: 实施组, children: null }
]
},
{
id: 1111, text: 销售部, children: null
}
]
function showJson() {
var json = eval('[{ id: 0, text: "技术部", children:[{ id: 4, text: "研发组",children:[{ id: 3, text: "程序员", children: null },{ id: 5, text: "测试员", children: null }]},{ id: 2, text: "实施组", children: null }]},{id: 1111, text: "销售部", children: null}]');
alert(json);//如果输出是一个js的object就是对的,不对的是undefined
}
container:{
node:[
{
id:0,
text:'技术部',
node:{
id:4,
text:'研发组',
node:{
id:3,
text:'程序员'
}
}
},
{
id:5,
text:'测试员'
},
{
id:2,
text:'实施组'
},
{
id:1111,
text:'销售部'
}
]
}
}
这个地方的js可以!
children:[{ id: 4, text: "研发组",children:[{ id: 3, text: "程序员"},{ id: 5, text: "测试员"}],id: 2, text: "实施组"}],[{id: 1111, text: "销售部", children: null}]