Jump to content

paul9519

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

paul9519's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i am currently building a small client to take xml from a post http request and convert it to json i have run into a problem here is the code , it receives everything properly and it can print the xml; but i cant convert it to json or access any elements of the xml, its being really weird <?php $c = curl_init(); curl_setopt($c, CURLOPT_URL, 'https://api.octranspo1.com/v1.1/GetNextTripsForStop'); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, 'appID=00000&apiKey=000000000&stopNo=4316&routeNo=98'); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_FOLLOWLOCATION, true ); $response = curl_exec($c); $xml = simplexml_load_string($response) $json = json_encode($xml); echo $xml->asXML(); // this prints the whole xml echo $json; // this just prints {} curl_close( $c ); ?> and here is what it is returning <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetNextTripsForStopResponse xmlns="http://octranspo.com"> <GetNextTripsForStopResult> <StopNo xmlns="http://tempuri.org/">4316</StopNo> <StopLabel xmlns="http://tempuri.org/">BLOHM 1579</StopLabel> <Error xmlns="http://tempuri.org/" /> <Route xmlns="http://tempuri.org/"> <RouteDirection> <RouteNo>98</RouteNo> <RouteLabel>Tunney's Pasture</RouteLabel> <Direction>Northbound</Direction> <Error /> <RequestProcessingTime>20120406171014</RequestProcessingTime> <Trips> <Trip> <TripDestination>Tunney's Pasture</TripDestination> <TripStartTime>17:24</TripStartTime> <AdjustedScheduleTime>18</AdjustedScheduleTime> <AdjustmentAge>4.18</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6E - 60</BusType> <Latitude>45.374141</Latitude> <Longitude>-75.596715</Longitude> <GPSSpeed>59.9</GPSSpeed> </Trip> <Trip> <TripDestination>Tunney's Pasture</TripDestination> <TripStartTime>17:39</TripStartTime> <AdjustedScheduleTime>33</AdjustedScheduleTime> <AdjustmentAge>-1</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6E - 60</BusType> <Latitude /><Longitude /> <GPSSpeed /> </Trip> <Trip> <TripDestination>Tunney's Pasture</TripDestination> <TripStartTime>17:59</TripStartTime> <AdjustedScheduleTime>53</AdjustedScheduleTime> <AdjustmentAge>-1</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6E - 60</BusType> <Latitude /><Longitude /> <GPSSpeed /></Trip> </Trips> </RouteDirection> </Route> </GetNextTripsForStopResult> </GetNextTripsForStopResponse> </soap:Body> </soap:Envelope> Thanks for the help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.