请把下面的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>

解决方案 »

  1.   

    http://blog.csdn.net/bancxc/archive/2010/04/04/5450329.aspx
      

  2.   

    { "container": { "node": [ {"id": "0",  "node": [ {"id": "4",  "node": [ {"id":
    "3", "text": "程序员" }, {"id": "5", "text": "测试员" } ], "text": "研发组" }, {
    "id": "2", "text": "实施组" } ], "text": "技术部" }, {"id": "1111", "text": "销
    售部" } ] }}
      

  3.   

    我这样写不知道是否正确:
    [
        { 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
        }
    ]
      

  4.   


    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
    }
      

  5.   

    http://www.thomasfrank.se/xml_to_json.html
      

  6.   

    {
        container:{
            node:[
                {
                    id:0,
                    text:'技术部',
                    node:{
                        id:4,
                        text:'研发组',
                        node:{
                            id:3,
                            text:'程序员'
                        }
                    }
                },
                {
                    id:5,
                    text:'测试员'
                },
                {
                    id:2,
                    text:'实施组'
                },
                {
                    id:1111,
                    text:'销售部'
                }
            ]
        }
    }
      

  7.   

    http://www.thomasfrank.se/xml_to_json.html
    这个地方的js可以!
      

  8.   

    [{ id: 0, text: "技术部", 
    children:[{ id: 4, text: "研发组",children:[{ id: 3, text: "程序员"},{ id: 5, text: "测试员"}],id: 2, text: "实施组"}],[{id: 1111, text: "销售部", children: null}]
      

  9.   

    xml2json虽然可以用,但解析不完全,空节点的值他自动删除了,正在改这个东西!- -