正则表达式截取xml
Posted 冯亮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了正则表达式截取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);
以上是关于正则表达式截取xml的主要内容,如果未能解决你的问题,请参考以下文章