Forums

PHP

This topic is locked

problem while parsing xml file using php4

Posted 21 Nov 2006 10:20:33
1
has voted
21 Nov 2006 10:20:33 ASif Iqbal posted:
using php version = 4.x

i m generating geocode from google map service for my databse.
but i m not able to parse xml file getting an error massage:-
"Fatal error: Cannot instantiate non-existent class: minixmldoc".

it is very improtant me to solve this as soon as possible , so i need help of you people.. please see the example and if you need to ask query please reply me .. thanks in advance... please help me.

<?php
// Your Google Maps API key
$key = "ABQIAAAA1aofQtDFbM-H5m5oBc4CRhS_wy1sxhzAgsmXvfF8x0XHe1Q0_RQtAzuWuXZIXc3a5yRKNteobLopYg";

// Query the table
$query = "SELECT address_id, companyAddress, city, state FROM addresses";
$result = mysql_query($query) or die(mysql_error());

// Loop through each row, submit HTTP request, output coordinates
while (list($id, $address, $city, $state) = mysql_fetch_row($result))
{
$mapaddress = urlencode("$address $city $state";

// Desired address
$url = "maps.google.com/maps/geo?q=$mapaddress&output=xml&key=$key";

// Retrieve the URL contents
$page = file_get_contents($url);

// Parse the returned XML file
$xml = new SimpleXMLElement($page);

// Parse the coordinate string
list($longitude, $latitude, $altitude) = explode(",", $xml->Response->Placemark->Point->coordinates);

// Output the coordinates
echo "latitude: $latitude, longitude: $longitude <br />";
}

Reply to this topic