Fetching data from Oracle into XML - Google Maps API
Posted: Wed Aug 27, 2008 5:09 pm
I am trying to convert the Google Maps API example - Creating a Store Locator with PHP, MySQL & Google Maps - from MySQL to Oracle. I am almost done, but I am having a problem near the end where data from the database is added to XML. Can anyone help me?
[...]
//Program ok up to here, made connection, query database, etc, but then...
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each record
// Done like this with MySQL data and it works:
//while ($row = @mysql_fetch_assoc($result)){
// $node = $dom->createElement("marker");
// $newnode = $parnode->appendChild($node);
// $newnode->setAttribute("name", $row['id']);
// $newnode->setAttribute("address", $row['address']);
// $newnode->setAttribute("lat", $row['slat']);
// $newnode->setAttribute("lng", $row['slng']);
// $newnode->setAttribute("distance", $row['distance']);
//}
// How do I do this with Oracle? The following doesn't create a runtime error but it is returning 'documentElement is null
// or not an object', which means it ain't returning the data!
while ($row = oci_fetch_array ($statement, oci_assoc)) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['id']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['slat']);
$newnode->setAttribute("lng", $row['slng']);
$newnode->setAttribute("distance", $row['distance']);
}
// Break connection
oci_logoff($connection);
echo $dom->saveXML();
//End
[...]
//Program ok up to here, made connection, query database, etc, but then...
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each record
// Done like this with MySQL data and it works:
//while ($row = @mysql_fetch_assoc($result)){
// $node = $dom->createElement("marker");
// $newnode = $parnode->appendChild($node);
// $newnode->setAttribute("name", $row['id']);
// $newnode->setAttribute("address", $row['address']);
// $newnode->setAttribute("lat", $row['slat']);
// $newnode->setAttribute("lng", $row['slng']);
// $newnode->setAttribute("distance", $row['distance']);
//}
// How do I do this with Oracle? The following doesn't create a runtime error but it is returning 'documentElement is null
// or not an object', which means it ain't returning the data!
while ($row = oci_fetch_array ($statement, oci_assoc)) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['id']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['slat']);
$newnode->setAttribute("lng", $row['slng']);
$newnode->setAttribute("distance", $row['distance']);
}
// Break connection
oci_logoff($connection);
echo $dom->saveXML();
//End