Welcome to WebmasterWorld Guest from 54.196.86.89

Forum Moderators: open

Message Too Old, No Replies

Extracting data from complicated XML response

     
10:53 am on Oct 18, 2016 (gmt 0)

New User

joined:Sept 15, 2016
posts: 5
votes: 0


Hi

Welcome back to 2001.

I've been working on extracting data from XML responses. Some are easy and some are really complicated. I wrote code in ASP (all I have apart from PHP which I'm not familiar with) to pick up the XML response as a text file then search through it getting the data I need. As I said, some of the responses are simple, but below is an example of one that's not too easy to handle.

I just spent all day searching for a more direct solution to this problem that would allow me to load the XML file and iterate through the nodes and child nodes getting the data, but I cannot get anything to work. If there's no simple solution then it's back to substringing though the XML.

Does anyone have anything that can help me? There are some many more XML files that I will have to extract data from that I think I will go mad!

Thanks for reading.

All the best

Mick

-<VehAvailRSCore>
-<VehRentalCore ReturnDateTime="2017-01-05T10:00:00Z" PickUpDateTime="2016-12-23T10:00:00Z">
<PickUpLocation Name="Belfast - Airport - International" LocationCode="161" CodeContext="XXX"/>
<ReturnLocation Name="Belfast - Airport - International" LocationCode="161" CodeContext="XXX"/>
</VehRentalCore>
-<VehVendorAvails>
-<VehVendorAvail>
<Vendor CodeContext="XXX" Division="YYY" CompanyShortName="ZZZ" Code="78"/>
-<VehAvails>
-<VehAvail>
-<VehAvailCore Status="Available">
+<Vehicle CodeContext="XXX" Code="MCMR" BaggageQuantity="1" PassengerQuantity="4" DriveType="Unspecified" FuelType="Petrol" TransmissionType="Manual" AirConditionInd="true">
-<RentalRate>
-<VehicleCharges>
<VehicleCharge Purpose="602.VCP.X" IncludedInRate="true" TaxInclusive="true" Description="Breakdown assistance"/>
<VehicleCharge Purpose="30" IncludedInRate="true" TaxInclusive="true" Description="Airport fee"/>
...and it goes on and on and on....