Click to See Complete Forum and Search --> : Parsing XML from WSDL format using PHP


cooldht
05-21-2009, 10:04 AM
Hello all,

I have searched high and low, and cannot find anything to help me get to a certain tag in a wsdl returned XML document in PHP. I've tried every foreach statement I can think of, but somehow it just isn't working for me. Based on the XML returned below, can anyone shed some light on how I might get to the <Flight> tag? I'd like to get the data inside the flight tag, such as the Elapsedtime attribute and so on. If I can figure out how to access one tag and get it into a variable, I can probably figure out the rest. I'd really appreciate if anyone can shed some light. If I do a print_r command from PHP I can see the following XML in the source of the page: I'm trying to get to the data in the RESPONSE tag itself, but because the request tag is in there its giving me fits.

<FLIGHT_ENGINE version="1.0" xmlns:fe="http://www.xxx.com/schemas/flightengine">
<REQUEST ProdID="default" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<FlightTypes Direct="0" Free="1" Marketed="1" Double_Marketed="1"/><TimeOfTravel DateTime="2009-05-20T00:01" Plus="0" Minus="0"/><ReqDep><City CityCode="SIN" /></ReqDep>
<ReqArr><City CityCode="MEL" /></ReqArr>
<Parameters>
<Display MaxConnected="50" ShowNames="11111111" MaxDirects="999" Sort="DepTime" />
<Connection Circuity="170" MaxCT="1440" MinCT="0" MaxElapsedTime="2880" OnlineOnly="0" SameAirportOnly="0" EliminateSlowExtras="0" ExcludeAircraft="SST">
<OnlineExcept Mins="30" Pcnt="1.1" />
<InterAirportExcept Mins="30" Pcnt="1.1" />
<TFOA Mins="120" Pcnt="0.0" /></Connection>
<Direct MaxElapsedTime="2880" ExcludeAircraft="SST" />
</Parameters>
</REQUEST>

<RESPONSE xmlns:dt="urn:schemas-microsoft-com:datatypes">
<Flight ElapsedTime="1190" GroundTime="300" ArrDayOffset="0" Marketed="0">
<Dep Stops="00" LegID="1678340" Frequency=" 3 " DepTime="2009-05-20T00:15:00" ElapsedTime="225" CodeShareInd="0" EquipChangeInd="N">
<EffFrom>2009-05-20</EffFrom>
<EffTo>2010-05-18</EffTo>
<Equipment Code="320">Airbus Industrie A320</Equipment>
<Carrier Code="PR" FlightNumber="506">Philippine Airlines</Carrier>
<City CityCode="SIN">Singapore</City>
<Port PortCode="SIN">Singapore Changi Apt</Port>
</Dep>
<Via MCTTime="45">
<Arr ArrTime="2009-05-20T04:00:00">
<City CityCode="MNL">Manila</City>
<Port PortCode="MNL">Manila Ninoy Aquino International Apt</Port></Arr>
<Dep Stops="01" LegID="1186825" Frequency="1 34 " DepTime="2009-05-20T09:00:00" ElapsedTime="665" CodeShareInd="0" EquipChangeInd="N">
<EffFrom>2009-05-19</EffFrom>
<EffTo>2009-10-01</EffTo>
<Equipment Code="330">Airbus Industrie A330</Equipment>
<Carrier Code="PR" FlightNumber="211">Philippine Airlines</Carrier>
<City CityCode="MNL">Manila</City>
<Port PortCode="MNL">Manila Ninoy Aquino International Apt</Port>
</Dep>
</Via>
<Arr ArrTime="2009-05-20T22:05:00">
<City CityCode="MEL">Melbourne</City>
<Port PortCode="MEL">Melbourne Airport</Port>
</Arr>
</Flight>
</RESPONSE>
</FLIGHT_ENGINE>