2017-05-19 27 views
-1

PHPでsimplexml_load_stringを使用しています。この配列からnumberofrecordings,recordingidstarttimestoptimeを取得するにはどうすればよいですか?PHP SimpleXML - 文字列を読み取る

SimpleXMLElement Object 
(
    [@attributes] => Array 
     (
      [totalnumberofrecordings] => 2 
      [numberofrecordings] => 2 
     ) 

    [recording] => Array 
     (
      [0] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [diskid] => SD_DISK 
          [recordingid] => 123123312 
          [starttime] => 2017-05-18T11:40:00.173775Z 
          [starttimelocal] => 2017-05-18T03:40:00.173775-08:00 
          [stoptime] => 2017-05-18T12:15:01.155311Z 
          [stoptimelocal] => 2017-05-18T04:15:01.155311-08:00 
          [recordingtype] => continuous 
          [eventid] => continuous 
          [eventtrigger] => continuous 
          [recordingstatus] => completed 
          [source] => 1 
          [locked] => No 
         ) 

       ) 
    ) 
) 
+0

数($配列[ '記録を'])と仮定すると? – Anoxy

答えて

0

$xmlは、XMLオブジェクト

$numberofrecordings = $xml->attributes()->numberofrecordings; 
$recordingid = $xml->recording[0]->attributes()->recordingid; 
$starttime = $xml->recording[0]->attributes()->starttime; 
$stoptime = $xml->recording[0]->attributes()->stoptime; 
関連する問題