下面是个复杂的XML
<ct t="1321891205">
<rs>
<r id="534173060" u1="100001592223908" u2="1678223743" ds="1321768933" s1="293" s2="-10000" uc1="229979285" uc2="0" uf1="0" uf2="0" hr2="0" rc="0" dc="0" c1="68" c2="0" h1="229" h2="0">
<m1>asasdfdfasdf</m1>
<m2/>
</r>
</rs>
</ct>
转成数组怎么弄如果转成数组了我要转回原来的MXL怎么弄小弟实在不明白其实原理
求各位大神指点

解决方案 »

  1.   

    $xml = <<< XML
    <ct t="1321891205">
    <rs>
    <r id="534173060" u1="100001592223908" u2="1678223743" ds="1321768933" s1="293" s2="-10000" uc1="229979285" uc2="0" uf1="0" uf2="0" hr2="0" rc="0" dc="0" c1="68" c2="0" h1="229" h2="0">
    <m1>asasdfdfasdf</m1>
    <m2/>
    </r>
    </rs>
    </ct>
    XML;$x = simplexml_load_string($xml);
    SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [t] => 1321891205
            )    [rs] => SimpleXMLElement Object
            (
                [r] => SimpleXMLElement Object
                    (
                        [@attributes] => Array
                            (
                                [id] => 534173060
                                [u1] => 100001592223908
                                [u2] => 1678223743
                                [ds] => 1321768933
                                [s1] => 293
                                [s2] => -10000
                                [uc1] => 229979285
                                [uc2] => 0
                                [uf1] => 0
                                [uf2] => 0
                                [hr2] => 0
                                [rc] => 0
                                [dc] => 0
                                [c1] => 68
                                [c2] => 0
                                [h1] => 229
                                [h2] => 0
                            )                    [m1] => asasdfdfasdf
                        [m2] => SimpleXMLElement Object
                            (
                            )                )        ))echo $x->savexml();  <?xml version="1.0" ?> 
    - <ct t="1321891205">
    - <rs>
    - <r id="534173060" u1="100001592223908" u2="1678223743" ds="1321768933" s1="293" s2="-10000" uc1="229979285" uc2="0" uf1="0" uf2="0" hr2="0" rc="0" dc="0" c1="68" c2="0" h1="229" h2="0">
      <m1>asasdfdfasdf</m1> 
      <m2 /> 
      </r>
      </rs>
      </ct>
      

  2.   

    转换
    如果数组转XML,XML转数组
    而且这种XML这么复杂怎么转比较好
      

  3.   

    哥们,这转过来好像不是数组?
    如何转为数组?
    如果数组转XML??