正则表达式截取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);
作者:冯亮
         
能力有限,水平一般。如有错误,欢迎指正
原文地址:https://www.cnblogs.com/fengliang/p/7612845.html