SimpleXML Namespaces
Posted: Wed Feb 17, 2010 2:58 am
Hey, just wondering how I can make this code work.
and yes I have Google'd it.
I believe the issue is namespace related, if someone could kindly explain this to me.
Thanks, in advance.
--EDIT--
Nevermind, I got it working I simply had to register the namespace, and use xpath.
and yes I have Google'd it.
Code: Select all
$info = simplexml_load_file('http://api.hostip.info/?ip=72.65.29.163');
$country = $info->{'gml:featureMember'}->{'countryName'};
$coords = split(",", $info->ipLocation->{'gml:pointProperty'}->{'gml:Point'}->{'gml:coordinates'});
$lng = $coords[0];
$lat = $coords[1];
echo $country;
Thanks, in advance.
--EDIT--
Nevermind, I got it working I simply had to register the namespace, and use xpath.