note 96764 added to function.simplexml-load-file
| From: | Smokey at osu1 dot php dot net | Date: | Mon, 15 Mar 2010 06:16:47 +0000 |
| Subject: | note 96764 added to function.simplexml-load-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167026@lists.php.net to get a copy of this message | ||
for nested and same name values i'v made up this little bit for getting and displaying
multiable values from google's geocode when a exact match is not found it returns all close
matches in the following format(this is an abriged version of there output)
<Response>
<Placemark id="1">
<address> New York 24, NY, USA</address>
<AddressDetails>
..................
</AddressDetails>
<Point>
<coordinates>-73.5850086,40.7207442,0</coordinates>
</Point>
</Placemark>
<Placemark id="2">
<address>New York 27, NY, USA</address>
<AddressDetails>
...................
</AddressDetails>
<Point>
<coordinates>-72.8987835,40.8003588,0</coordinates>
</Point>
</Placemark>
<Placemark id="3">
<address>Cedar Place School, 20 Cedar Pl, Yonkers, NY 10705, USA</address>
<AddressDetails>
..................
</AddressDetails>
<Point>
<coordinates>-73.8966320,40.9256520,0</coordinates>
</Point>
</Placemark>
</Response>
<?php
// get and breakdown the results then store them in $var's
$Address = "99999 parkplace, new york, NY";
$urladdress = urlencode($Address);
$Base_url = "http://maps.google.com/maps/geo?q=";
$urlParts = "&output=xml";
$urlrequest = $Base_url . $urladdress . $urlParts;
$xml = simplexml_load_file($urlrequest);
$num = "0";
foreach ($xml->Response->Placemark as $value){
$num++;
$GeoFindAdd{$num} = $value->address;
$GeoFindCords{$num} = $value->Point->coordinates;
}
// a simple display for the results
echo "Found ",$num," Possable Geo Data Sets <br>";
$CountNumResults = "0";
for ( ; $num > 0; $num--){
$CountNumResults++;
echo $countnum,"<br> Address = ",$GeoFindAdd{$num},"<br> Coordinates =
",$GeoFindCords{$num},"<br>";
}
echo "END";
?>
----
Server IP: 64.71.164.2
Probable Submitter: 174.101.247.4
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-load-file.php
Edit -- https://master.php.net/note/edit/96764
Del: integrated -- https://master.php.net/note/delete/96764/integrated
Del: useless -- https://master.php.net/note/delete/96764/useless
Del: bad code -- https://master.php.net/note/delete/96764/bad+code
Del: spam -- https://master.php.net/note/delete/96764/spam
Del: non-english -- https://master.php.net/note/delete/96764/non-english
Del: in docs -- https://master.php.net/note/delete/96764/in+docs
Del: other reasons-- https://master.php.net/note/delete/96764
Reject -- https://master.php.net/note/reject/96764
Search -- https://master.php.net/manage/user-notes.php