I am trying to create an xml file, but the $dom->savexml() gives nothing, and there is no error message so i don't know how to debug. Here's my php file:
require_once 'logincredentials.php';
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$paode = $dom->appendChild($node);
// Opens a coection to a MySQL server
$co = new mysqli($hostname, $useame, $password, $dbname);
if ($co->coect_error)
{
die($co->coect_error);
exit();
}
//mysqli_set_charset($co, 'utf8');
// Select all the rows in the markers table
$query = "SELECT * FROM markers";
$result = $co->query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
Header("Content-Type: text/html");
// Iterate through the rows, adding XML nodes for each
while($row = $result->fetch_assoc()) {
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $paode->appendChild($node);
$newnode->setAttribute("name",$row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("type", $row['type']);
}
echo $dom->saveXML();
I have copied this code and adjusted it to my needs, it's from a tutorial from google developers. The db coection is fine and the query is executed correctly.
