Hi everybody, I am new in the forum... I have this problem:
Parse error: syntax error, unexpected ':'
Phpcode
<?php
$search_artist=$_POST["textfield4"];
$url='http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist='.$search_artist.'&api_key=b25b959554ed76058ac220b7b2e0a026';
$lfm = simplexml_load_file($url);
$name=$lfm->events->event[0]->venue->name;
$lat=$lfm->events->event[0]->venue->location->geo: point->geo:lat;
?>
XMLfile
<geo: point>
<geo:lat>36.116143</geo:lat>
<geo:long>-115.176416</geo:long>
</geo: point>
How can I get geo:lat value ;:crying:
SimpleXML problem
Started by mavmak, May 20 2010 12:24 AM
4 replies to this topic
#1
Posted 20 May 2010 - 12:24 AM
|
|
|
#2
Posted 20 May 2010 - 09:33 AM
you need to do it like this: {'geo:lat'} and {'geo: point'}
$lat=$lfm->events->event[0]->venue->location->{'geo: point'}->{'geo:lat'};
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#3
Posted 20 May 2010 - 12:05 PM
Orjan said:
you need to do it like this: {'geo:lat'} and {'geo: point'}
$lat=$lfm->events->event[0]->venue->location->{'geo: point'}->{'geo:lat'};
It doesn't seem to work...
I use
echo $lfm->events->event[0]->venue->name;
echo $lfm->events->event[0]->venue->location->{'geo: point'}->{'geo:lat'};
but the output is only the name... :crying:
#4
Posted 20 May 2010 - 12:50 PM
you can also try
echo (string)$lfm->events->event[0]->venue->location->{'geo: point'}->{'geo:lat'};
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#5
Posted 20 May 2010 - 08:56 PM
Finally I found the solution:
$lfm = simplexml_load_file($url);
$ns = $lfm->getNamespaces(true);
$geo=$lfm->events->event[0]->venue->location->children($ns[geo]);
$lat = $geo->point->lat[0];
$long = $geo->point->long[0];
echo $lat.' | '.$long;
$lfm = simplexml_load_file($url);
$ns = $lfm->getNamespaces(true);
$geo=$lfm->events->event[0]->venue->location->children($ns[geo]);
$lat = $geo->point->lat[0];
$long = $geo->point->long[0];
echo $lat.' | '.$long;


Sign In
Create Account

Back to top









