シンプルなXMLファイルの場合

xml.xml

実行結果

array(8) {
  ["userFname"]=>
  string(6) "太朗"
  ["userLname"]=>
  string(6) "山田"
  ["userFullName"]=>
  string(12) "山田太朗"
  ["userEmail"]=>
  string(16) "taro@example.com"
  ["userPhone"]=>
  string(10) "00-00-0000"
  ["userAddress"]=>
  string(21) "北海道苫小牧市"
  ["TravelerInfo"]=>
  array(4) {
    ["TravelerFName"]=>
    string(6) "太朗"
    ["TravelerLName"]=>
    string(6) "山田"
    ["TravelerEmail"]=>
    string(16) "taro@example.com"
    ["TravelerPhone"]=>
    string(10) "00-00-0000"
  }
  ["TravelInfo"]=>
  array(3) {
    ["DurationStartDate"]=>
    string(10) "2013-12-08"
    ["DurationEndDate"]=>
    string(10) "2013-12-14"
    ["TravelDestination"]=>
    array(2) {
      ["State"]=>
      string(6) "京都"
      ["City"]=>
      string(9) "京都市"
    }
  }
}
    

 

名前空間が定義されている場合など

xml2.xml

実行結果

array(9) {
  ["@attributes"]=>
  array(1) {
    ["xmlns_my"]=>
    string(21) "http_//studio-key.com"
  }
  ["my_userFname"]=>
  string(6) "太朗"
  ["my_userLname"]=>
  string(6) "山田"
  ["my_userFullName"]=>
  string(12) "山田太朗"
  ["my_userEmail"]=>
  string(16) "taro@example.com"
  ["my_userPhone"]=>
  string(10) "00-00-0000"
  ["my_userAddress"]=>
  string(21) "北海道苫小牧市"
  ["my_TravelerInfo"]=>
  array(4) {
    ["my_TravelerFName"]=>
    string(6) "太朗"
    ["my_TravelerLName"]=>
    string(6) "山田"
    ["my_TravelerEmail"]=>
    string(16) "taro@example.com"
    ["my_TravelerPhone"]=>
    string(10) "00-00-0000"
  }
  ["my_TravelInfo"]=>
  array(3) {
    ["my_DurationStartDate"]=>
    string(10) "2013-12-08"
    ["my_DurationEndDate"]=>
    string(10) "2013-12-14"
    ["my_TravelDestination"]=>
    array(2) {
      ["my_State"]=>
      string(6) "京都"
      ["my_City"]=>
      string(9) "京都市"
    }
  }
}