Given the following XML file:
<FlightHistoryGetRecordsResponse>
−
<FlightHistory
DepartureAirportTimeZoneOffset="2" ArrivalAirportTimeZoneOffset="1"
ActualAirTime="101" ActualAircraftType="319"
ActualBlockTime="124" ActualGateArrivalDate="2010-07-10T11:58:00.000"
ActualGateDepartureDate="2010-07-10T10:54:00.000"
ActualRunwayArrivalDate="2010-07-10T11:52:00.000"
ActualRunwayDepartureDate="2010-07-10T11:11:00.000"
ArrivalDate="2010-07-10T12:05:00.000" ArrivalTerminal="5"
CreatorCode="O" DepartureDate="2010-07-10T11:05:00.000" DepartureTerminal=""
EstimatedGateArrivalDate="2010-07-10T11:48:00.000"
EstimatedGateDepartureDate="2010-07-10T11:05:00.000"
FlightHistoryId="197151356" FlightNumber="991"
PublishedArrivalDate="2010-07-10T12:05:00.000"
PublishedDepartureDate="2010-07-10T11:05:00.000" ScheduledAircraftType="319"
ScheduledBlockTime="120" ScheduledGateArrivalDate="2010-07-10T12:05:00.000"
ScheduledGateDepartureDate="2010-07-10T11:05:00.000"
Status="Landed" StatusCode="L">
<Airline AirlineCode="BA" IATACode="BA" ICAOCode="BAW" Name="British Airways"/>
<Origin AirportCode="TXL" IATACode="TXL" ICAOCode="EDDT" Name="Tegel Airport"/>
<Destinat开发者_如何学Goion AirportCode="LHR" IATACode="LHR" ICAOCode="EGLL" Name="Heathrow Airport"/>
</FlightHistory>
</FlightHistoryGetRecordsResponse>
I want to fetch the below details from that XML TAG using PHP:
- ArrivalTerminal
- Status
- StatusCode
- ScheduledGateArrivalDate
- ActualGateArrivalDate
How do I fetch the above details?
$xmlObj = simplexml_load_string($xmlString);
$arrivalTerminal = (string)$xmlObj->FlightHistory['ArrivalTerminal'];
$status = (string)$xmlObj->FlightHistory['Status'];
$statusCode = (string)$xmlObj->FlightHistory['StatusCode'];
$scheduledGateArrivalDate = (string)$xmlObj->FlightHistory['ScheduledGateArrivalDate'];
$actualGateArrivalDate = (string)$xmlObj->FlightHistory['ActualGateArrivalDate'];
精彩评论