Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] [XML] Pobieranie danych
Forum PHP.pl > Forum > Przedszkole
Killerek
Witam, możecie mi napisać dlaczego nie mogę pobrać danych z tego xml:
  1. <GeocodeResponse>
  2. <status>OK</status>
  3. <result>
  4. <type>street_address</type>
  5. <formatted_address>
  6. 1600 Pennsylvania Avenue Northwest, President's Park, Waszyngton, Dystrykt Kolumbii 20500, Stany Zjednoczone
  7. </formatted_address>
  8. <address_component>
  9. <long_name>1600</long_name>
  10. <short_name>1600</short_name>
  11. <type>street_number</type>
  12. </address_component>
  13. <address_component>
  14. <long_name>President's Park</long_name>
  15. <short_name>President's Park</short_name>
  16. <type>establishment</type>
  17. </address_component>
  18. <address_component>
  19. <long_name>Pennsylvania Avenue Northwest</long_name>
  20. <short_name>Pennsylvania Ave NW</short_name>
  21. <type>route</type>
  22. </address_component>
  23. <address_component>
  24. <long_name>Waszyngton</long_name>
  25. <short_name>Waszyngton</short_name>
  26. <type>locality</type>
  27. <type>political</type>
  28. </address_component>
  29. <address_component>
  30. <long_name>Dystrykt Kolumbii</long_name>
  31. <short_name>DC</short_name>
  32. <type>administrative_area_level_1</type>
  33. <type>political</type>
  34. </address_component>
  35. <address_component>
  36. <long_name>Stany Zjednoczone</long_name>
  37. <short_name>US</short_name>
  38. <type>country</type>
  39. <type>political</type>
  40. </address_component>
  41. <address_component>
  42. <long_name>20500</long_name>
  43. <short_name>20500</short_name>
  44. <type>postal_code</type>
  45. </address_component>
  46. <geometry>
  47. <location>
  48. <lat>38.8970960</lat>
  49. <lng>-77.0365450</lng>
  50. </location>
  51. <location_type>ROOFTOP</location_type>
  52. <viewport>
  53. <southwest>
  54. <lat>38.8957470</lat>
  55. <lng>-77.0378940</lng>
  56. </southwest>
  57. <northeast>
  58. <lat>38.8984450</lat>
  59. <lng>-77.0351960</lng>
  60. </northeast>
  61. </viewport>
  62. </geometry>
  63. </result>
  64. </GeocodeResponse>


Tym kodem:
  1. $xml_load = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?address=1600%20Pennsylvania%20Ave%20NW,%20Washington,%20DC%2020500,%20Stany%20Zjednoczone&sensor=false');
  2. $lat = $xml_load->GeocodeResponse->result->geometry->location->lat;
  3. $lng = $xml_load->GeocodeResponse->result->geometry->location->lng;
  4.  
  5. echo $lat.', '.$lng;
Damonsson
Po co to GeocodeResponse? Wywal.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.