2013-11-15 81 views
0

我想找出一種方法來提取使用SimpleXML flickr api XML請求的經度和緯度。簡單的XML與Flickr API

我曾嘗試以下的SimpleXML PHP腳本:

<?php 
$xml = simplexml_load_file("http://api.flickr.com/services/rest/?method=flickr.places.placesForTags&api_key=XXXX&place_type_id=7&tags=Defenders+of+Wildlife&format=rest&auth_token=XXXX-XXXX&api_sig=XXXX"); 

foreach ($xml->places->place as $item) { 

print "<p>"; 
print $item->latitude; 
print "," 
print $item->longitude; 
print "</p>"; 
print "<br>"; 
} 
?> 

這裏是XML的URL API請求的文檔樹:

<rsp stat="ok"> 
<places total="97"> 
<place place_id="Ayf3HfhQVrOfB2kB" woeid="1492513" latitude="-18.947" longitude="48.521" place_url="/Madagascar/Toamasina/Andasibe" place_type="locality" place_type_id="7" timezone="Indian/Antananarivo" woe_name="Andasibe" photo_count="63">Andasibe, Toamasina, Madagascar</place> 
<place place_id="gTWfoV5WU7jJ3tE" woeid="712142" latitude="39.173" longitude="8.976" place_url="/Italy/Sardinia/Capoterra" place_type="locality" place_type_id="7" timezone="Europe/Rome" woe_name="Capoterra" photo_count="44">Capoterra, Sardinia, Italy</place> 
</places> 
</rsp> 

我如何能得到公正的經度任何建議和緯度打印?

謝謝!

回答