① php 解析xml
看著這些代碼,好厲害的樣子,程序員牛
② php 如何解析xml格式字元串
//假設xml字元串
$postStr = '<xml><ToUserName><![CDATA[toUser]]></ToUserName><FromUserName><![CDATA[FromUser]]></FromUserName><CreateTime>123456789</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[p1]]></Content></xml>';
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
var_mp($postObj);
/**
object(SimpleXMLElement)[16] public 'ToUserName' => string 'toUser' (length=6) public 'FromUserName' => string 'FromUser' (length=8) public 'CreateTime' => string '123456789' (length=9) public 'MsgType' => string 'text' (length=4) public 'Content' => string 'p1' (length=2)
*/
//把xml字元串解析為對象