I'm trying to parse OTA service's XML response in PHP. I have tried below code but no luck.
$doc = new DOMDocument();
$doc->loadXML($response);
$XMLresults = $doc->getElementsByTagName("OTA_VehAvailRateRS");
I want to get different tags value from xml response. Can someone help me out from this? Thanks. For example i want to parse following xml response:
<?xml version="1.0"?>
<OTA_VehAvailRateRS xmlns="http://www.opentravel.org/OTA/2003/05" TimeStamp="2018-02-28T01:12:27" Target="Test" Version="4.500" SequenceNmbr="1">
<Success/>
<VehAvailRSCore>
<VehRentalCore PickUpDateTime="2018-03-13T08:00:00" ReturnDateTime="2018-03-30T08:00:00">
<PickUpLocation LocationCode="TEST"/>
<ReturnLocation LocationCode="TEST"/>
</VehRentalCore>
<VehVendorAvails>
<VehVendorAvail>
<VehAvails> <VehAvail>
<VehAvailCore Status="Available">
<Vehicle Code="TEST15" VendorCarType="TEST15" Description="TEST"/>
<RentalRate>
<RateDistance Unlimited="True" DistUnitName="Mile" VehiclePeriodUnitName="RentalPeriod"/>
<VehicleCharges>
<VehicleCharge Description="TEST" Amount="1299.35" CurrencyCode="" GuaranteedInd="True" Purpose="1"> <Calculation UnitCharge="33.32" UnitName="Hour"/>
<Calculation UnitCharge="1560.00" UnitName="Month"/>
<Calculation UnitCharge="499.75" UnitName="Week"/>
<Calculation UnitCharge="99.95" UnitName="Day"/>
<TaxAmounts> </TaxAmounts>
</VehicleCharge>
</VehicleCharges>
</RentalRate>
<Fees> </Fees>
<TotalCharge CurrencyCode="" RateTotalAmount="1299.35" EstimatedTotalAmount="1299.35"/>
<PricedEquips> </PricedEquips> </VehAvailCore> <VehAvailInfo> <PricedCoverages> </PricedCoverages> </VehAvailInfo> </VehAvail> </VehAvails> </VehVendorAvail> </VehVendorAvails> </VehAvailRSCore> </OTA_VehAvailRateRS>