正则表达式截取xml

$str = '<Ips><GateWayRsp><head><ReferenceID>123</ReferenceID><RspCode>000000</RspCode><RspMsg><![CDATA[成功]]></RspMsg><ReqDate>20170928102447</ReqDate><RspDate></RspDate><Signature>eed5b1e42d5a5fb0a6ef569ccec76cef</Signature></head><body><MerBillNo>201709250000010947-iMcL2O9jx</MerBillNo><CurrencyType>156</CurrencyType><Amount>0.02</Amount><ExchangeRate>1</ExchangeRate><RMBAmount>0.02</RMBAmount><Date>20170928</Date><Status>Y</Status><Msg><![CDATA[支付成功!]]></Msg><Attach><![CDATA[Fannie]]></Attach><IpsBillNo>BO20170928102638023091</IpsBillNo><IpsTradeNo>2017092810570071678</IpsTradeNo><RetEncodeType>17</RetEncodeType><BankBillNo>7110862177</BankBillNo><ResultType>0</ResultType><IpsBillTime>20170928105909</IpsBillTime></body></GateWayRsp></Ips>';
preg_match('/(?<=<\/head>)(.*)(?=<\/GateWayRsp>)/', $str, $match);

posted on 2017-09-29 21:30  冯亮  阅读(552)  评论(0编辑  收藏  举报

导航