<?
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM Listing_Arnona WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("Price",$row['Price']);
$newnode->setAttribute("PriceS", $row['Price']);
$newnode->setAttribute("address", $row['street_name']);
$newnode->setAttribute("NumRooms", $row['Room_Num']);
$newnode->setAttribute("PROMO", $row['PROMO']);
}
$dom->formatOutput = true;
$test1 = $dom->saveXML(); // put string in test1
$dom->save('test1.xml'); // save as file
?>
答案 0 :(得分:1)
每个人都指出的问题是写作权限。我用chmod 777打开了一个新的文件夹名'xml',并将代码更改为:
$dom->save('xml/test1.xml');
谢谢大家。