0
집에서 대시 보드에 포함 할 OCTranspo 피드의 데이터를 중지하려고합니다. OCTranspo API를 사용하면이 데이터를 얻을 수 있습니다.이 데이터는 PHP에서 성공적으로 실행되었습니다.PHP의 SOAP XML 피드 구문 분석
<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/">9085</stopno>
<stoplabel xmlns="http://tempuri.org/">FERNBANK BRIGHTSIDE</stoplabel>
<error xmlns="http://tempuri.org/">
<route xmlns="http://tempuri.org/">
<routedirection>
<routeno>61</routeno>
<routelabel>Terry Fox</routelabel>
<direction>Westbound</direction>
<error>
<requestprocessingtime>20171222231738</requestprocessingtime>
<trips>
<trip>
<tripdestination>Stittsville</tripdestination>
<tripstarttime>21:57</tripstarttime>
<adjustedscheduletime>1</adjustedscheduletime>
<adjustmentage>0.82</adjustmentage>
<lasttripofschedule>false</lasttripofschedule>
<bustype>6LB - 60</bustype>
<latitude>45.248670</latitude>
<longitude>-75.912157</longitude>
<gpsspeed>48.9</gpsspeed>
</trip>
<trip>
<tripdestination>Stittsville</tripdestination>
<tripstarttime>22:27</tripstarttime>
<adjustedscheduletime>35</adjustedscheduletime>
<adjustmentage>0.47</adjustmentage>
<lasttripofschedule>false</lasttripofschedule>
<bustype>6EB - 60</bustype>
<latitude>45.343510</latitude>
<longitude>-75.820002</longitude>
<gpsspeed>74.1</gpsspeed>
</trip>
<trip>
<tripdestination>Stittsville</tripdestination>
<tripstarttime>22:57</tripstarttime>
<adjustedscheduletime>69</adjustedscheduletime>
<adjustmentage>0.88</adjustmentage>
<lasttripofschedule>false</lasttripofschedule>
<bustype>6EB - 60</bustype>
<latitude>45.419260</latitude>
<longitude>-75.656651</longitude>
<gpsspeed>40.0</gpsspeed>
</trip>
</trips>
</error>
</routedirection>
</route>
</error>
</getnexttripsforstopresult>
</getnexttripsforstopresponse>
</soap:body>
</soap:envelope>
, '경로 : 여기
내가지고있어 그 응답의 사본입니다 숫자 '및'방향 '뿐만 아니라 나열된 세 가지 여행 각각에 대한'조정 된 시간 '을 보여줍니다.응답을 잘로드 할 수 있지만 XML 피드를 구문 분석 할 PHP 페이지를 가져올 수 없습니다. 여기
내가 지금까지 시도한 것입니다 :
<?php
$mySoapResponse=file_get_contents('https://api.octranspo1.com/v1.2/GetNextTripsForStop?appID={ID}&apiKey={key}&routeNo=61&stopNo=9085');
echo $mySoapResponse;
?>
<br>
<hr>
<br>
<?php
// Loads the XML
$soap = simplexml_load_string($mySoapResponse);
$soap->registerXPathNamespace('ns1', 'http://raspberrypi.local/');
// Grabs the trips
$trips = $soap->xpath('/ns1:getnexttripsforstopresponse/ns1:getnexttripsforstopresult/ns1:error/ns1:route/ns1:routedirection/ns1:error/ns1:trips');
$label = $soap->xpath('/ns1:getnexttripsforstopresponse/ns1:getnexttripsforstopresult/ns1:stoplabel');
echo $label[0];
//$trips = $xml->children('soap', true)->Body->getnexttripsforstopresponse->getnexttripsforstopresult->error->route->routedirection->error->trips->trip;
// Take the posts and generate some markup
foreach ($trips as $trip)
{
echo '
<p>' . $trip->tripstarttime . '</p>
<p>' . $trip->adjustedscheduletime . '</p>
<p>' . $trip->bustype . '</p>
';
}
?>
https://stackoverflow.com/questions/4194489/how-to-parse-soap-xml을 :
여기 내 마지막 코드입니까? –