$xml = file_get_contents($url); $data = new SimpleXMLElement($xml);
SimpleXMLElement Object ( [@attributes] => Array ( [timestamp] => Sat, 15 Jun 13 20:02:13 +0000 [attribution] => Data Š OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright [querystring] => Bucharest-Romania [polygon] => false [exclude_place_ids] => 331526 [more_url] => http://nominatim.openstreetmap.org/search?format=xml&exclude_place_ids=331526&q=Bucharest-Romania ) [place] => SimpleXMLElement Object ( [@attributes] => Array ( [place_id] => 331526 [osm_type] => node [osm_id] => 96209423 [place_rank] => 15 [boundingbox] => 44.4361381530762,44.4361419677734,26.1027431488037,26.1027450561523 [lat] => 44.436139 [lon] => 26.1027436 [display_name] => BucureČti, Sector 2, Bucuresti, România, European Union [class] => place [type] => city [importance] => 0.73231672860554 [icon] => http://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png ) ) )
$lat = $data->place[0]->lat; $lon = $data->place[0]->lon;
$lat = strval($data->place[0]->attributes()->lat); $lon = strval($data->place[0]->attributes()->lon);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)