php处理xml成数组

$res = '<?xml version="1.0" encoding="utf-8" ?><returnsms>
<returnstatus>Success</returnstatus>
<message>ok</message>
<remainpoint>1</remainpoint>
<taskID>11513955</taskID>
<successCounts>1</successCounts></returnsms>';

$xml = simplexml_load_string($res); // 返回对象
$json = json_encode($xml); // encode
$array = json_decode($json,TRUE); // decode成数组
array(5) {
  ["returnstatus"] => string(7) "Success"
  ["message"] => string(2) "ok"
  ["remainpoint"] => string(1) "1"
  ["taskID"] => string(8) "11513955"
  ["successCounts"] => string(1) "1"
}
posted @ 2020-02-19 11:14  TBHacker  阅读(211)  评论(0编辑  收藏  举报