用simplexml解析xml到數組

 
$xml = <<<xml
         <xml>      
            <ToUserName><![CDATA[toUser]]></ToUserName>      
            <FromUserName><![CDATA[fromUser]]></FromUserName>      
            <CreateTime>1348831860</CreateTime>      
            <MsgType><![CDATA[text]]></MsgType>      
            <Content><![CDATA[this is a test]]></Content>          
            <MsgId>1234567890123456</MsgId>  
         </xml>
xml;
        $xmls = simplexml_load_string($xml,'SimpleXMLElement',LIBXML_NOCDATA);
        $data = json_decode(json_encode($xmls),true);
相關文章
相關標籤/搜索