I have the following xml file. How can I reach to each element?
xml file:
<SOAP:Envelope xmlns:SOAP="http://ift.tt/sVJIaE">
<SOAP:Body>
<air:LowFareSearchRsp TransactionId="FC79C79F0A0764772ABBB37084848BA2"
ResponseTime="11236" DistanceUnits="MI" CurrencyType="AUD"
xmlns:air="http://ift.tt/1oXRNLw">
<air:AirPricingSolution Key="0T" TotalPrice="AUD714.30"
BasePrice="LKR51100" ApproximateTotalPrice="AUD714.30"
ApproximateBasePrice="AUD446.00" EquivalentBasePrice="AUD446.00"
Taxes="AUD268.30">
<air:Journey TravelTime="P0DT11H30M0S">
<air:AirSegmentRef Key="109T" />
</air:Journey>
<air:LegRef Key="1T" />
<air:AirPricingInfo Key="2T" TotalPrice="AUD714.30"
BasePrice="LKR51100" ApproximateTotalPrice="AUD714.30"
ApproximateBasePrice="AUD446.00" EquivalentBasePrice="AUD446.00"
Taxes="AUD268.30" LatestTicketingTime="2014-08-23T23:59:00.000+00:00"
PricingMethod="Guaranteed" Refundable="true" ETicketability="Yes"
PlatingCarrier="UL" ProviderCode="1G">
<air:FareInfoRef Key="6T" />
<air:BookingInfo BookingCode="W" CabinClass="Economy"
FareInfoRef="6T" SegmentRef="109T" />
<air:TaxInfo Category="EJ" Amount="AUD66.60" />
<air:TaxInfo Category="LK" Amount="AUD27.80" />
<air:TaxInfo Category="YQ" Amount="AUD173.90" />
<air:FareCalc>CMB UL LON 392.17WOWLK NUC392.17END ROE130.298
</air:FareCalc>
<air:PassengerType Code="ADT" />
<air:ChangePenalty>
<air:Amount>AUD43.00</air:Amount>
</air:ChangePenalty>
</air:AirPricingInfo>
</air:AirPricingSolution>
</air:LowFareSearchRsp>
</SOAP:Body>
</SOAP:Envelope>
So far I tried with XPath. But It is not possible to write the xpath for each and every element. My php code is as below.
foreach ($xml->xpath('//SOAP:Envelope/SOAP:Body/air:AvailabilitySearchRsp/air:AirPricingSolution') as $segmentData) {
$airSegmentRef = $segmentData->Journey->AirSegmentRef; // This is not working, shows an error.
}
How can I access inner elements like this? Can anyone suggest how can I solve this?
No comments:
Post a Comment