Hi all,
I have been trying to parse an XML file using SimpleXMLElemen t in PHP 5, but
am having difficulty fetching any results.
I have an airport code in a variable, $mapaddress (for example: KTEB), that I am trying to pass to Geoname.us, which will geocode the airport code and return latitude and longitude coordinates in the form of an XML file. To see the kind of file Geoname returns, click here to see the result for the code "KTEB": http://ws.geonames.org/search?name=KTE B&fcode=AIRP
I need to parse the lat and lng from the returned xml file and save them as $latitude and $longitude, but I am getting nothing. Here is the code:
[PHP]$urlair = "http://ws.geonames.org/search?name=$ma paddress&fcode= AIRP";
$pageair = file_get_conten ts($urlair);
$xmlair = new SimpleXMLElemen t($pageair);
$longitude = ($xmlair->geonames->geoname->lng);
$latitude = ($xmlair->geonames->geoname->lat);
$code = ($xmlair->geonames->totalResultsCo unt); [/PHP]
Any suggestions from anybody would be greatly appreciated.
Nick
I have been trying to parse an XML file using SimpleXMLElemen t in PHP 5, but
am having difficulty fetching any results.
I have an airport code in a variable, $mapaddress (for example: KTEB), that I am trying to pass to Geoname.us, which will geocode the airport code and return latitude and longitude coordinates in the form of an XML file. To see the kind of file Geoname returns, click here to see the result for the code "KTEB": http://ws.geonames.org/search?name=KTE B&fcode=AIRP
I need to parse the lat and lng from the returned xml file and save them as $latitude and $longitude, but I am getting nothing. Here is the code:
[PHP]$urlair = "http://ws.geonames.org/search?name=$ma paddress&fcode= AIRP";
$pageair = file_get_conten ts($urlair);
$xmlair = new SimpleXMLElemen t($pageair);
$longitude = ($xmlair->geonames->geoname->lng);
$latitude = ($xmlair->geonames->geoname->lat);
$code = ($xmlair->geonames->totalResultsCo unt); [/PHP]
Any suggestions from anybody would be greatly appreciated.
Nick
Comment