php对xml的处理

$paymentResult  =

$ips='<Ips><GateWayRsp><head><ReferenceID></ReferenceID><RspCode>000000</RspCode><RspMsg><![CDATA[交易成功!]]></RspMsg><ReqDate>20160613144542</ReqDate><RspDate>20160613144627</RspDate><Signature>1c377812dfb935a3dd8934ac455dfb3f</Signature></head><body><MerBillNo>7775020160613024838921</MerBillNo><CurrencyType>156</CurrencyType><Amount>1950</Amount><Date>20160613</Date><Status>Y</Status><Msg><![CDATA[支付成功!]]></Msg><Attach><![CDATA[wjg201518_Andy_536354]]></Attach><IpsBillNo>BO2016061314454224926</IpsBillNo><IpsTradeNo>2016061302064237978</IpsTradeNo><RetEncodeType>17</RetEncodeType><BankBillNo>7108288387</BankBillNo><ResultType>0</ResultType><IpsBillTime>20160613144627</IpsBillTime></body></GateWayRsp></Ips>';

 

$xml=simplexml_load_string($paymentResult,'SimpleXMLElement', LIBXML_NOCDATA);

  $post = array();
   //读取相关xml中信息
  $RspCodesx = $xml->xpath("GateWayRsp/head/RspCode");//响应编码
  $RspCode = $RspCodesx[0];
  $errCode = (array)$RspCode ;
  $post['errCode'] = $errCode[0] ;

posted @ 2016-06-16 11:24  ylong52  阅读(199)  评论(0编辑  收藏  举报