XML 형식으로 응답을 보내는 API에 요청을 보내고 있습니다.PHP에서 file_get_contents로 PHP에서 데이터 추출
응답은 다음과 같습니다 : 나는 hotelId 또는 이름과 같은 개별 값을 인쇄 할 수 있도록
<ns2:HotelInformationResponse hotelId="263933">
<customerSessionId>0ABAAA85-112B-0914-9322-CA866D907EF8</customerSessionId>
<HotelSummary order="0">
<hotelId>263933</hotelId>
<name>Nova Platinum Hotel</name>
<address1>562 Moo 10 Pratamnak Road, Nongprue</address1>
<address2>Banglamung</address2>
<city>Pattaya</city>
<postalCode>20260</postalCode>
<countryCode>TH</countryCode>
가 어떻게이 데이터를받을 수 있나요?
는이 같은 시도 :
또한$Geosearch = 'APICALLURLHERE';
$fileContents = file_get_contents($Geosearch);
$string_data = $fileContents;
$xml = simplexml_load_string($string_data);
$hotel_id = (string) $xml->hotelId;
$hotel_name = (string) $xml->name;
echo $hotel_id.' '.$hotel_name;
나는이 시도 :
$xml = simplexml_load_file("APICALLURLHERE");
echo $xml->hotelId;
echo $xml->name;
전체 응답은 여기에 있습니다 : 원격에
http://paste.ofcode.org/9VAH6jBUPJ4mHaMNkiS44d
을하는 방식의'hotelId'하지'HotelId'에 의해. 그래서 문제가 뭐야? – Ghost
그것은 오타 였지만 어쨌든 어떤 차이도 만들지 않습니다. – user327685
이 완전한 응답입니까? –