我試圖將標記放置在谷歌地圖上,基於mysql db中提交的值。當使用PHP動態加載xml時,由於responseXML.DocumentElement屬性沒有得到重視,因此沒有標記被放置在地圖上。它在我從一個靜態文件加載XML時起作用,而不是從一個數據庫動態加載時。從PHP錯誤加載XML:Microsoft.XMLHTTP.DocumentElement null
這裏是行不通的頁面:http://www.thirstygolfer.com/utils/maptest2.html
下面是對頁面:http://www.thirstygolfer.com/utils/maptest1.html
這是PHP文件生成XML:www.thirstygolfer.com/utils/xmldump3.php
這裏是thirstygolfer.com/utils/xmldump3.php(減去數據庫連接信息)的PHP代碼:
<?php
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
$result=mysql_query("SELECT * FROM Main WHERE State='MA' and FirstLetter='A'");
header("Content-type: text/xml");
while ($row = mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("id",$row['id']);
$newnode->setAttribute("lat", $row['Lat']);
$newnode->setAttribute("lng", $row['Lon']);
}
echo $dom->saveXML();
?>
請幫助!
謝謝!我添加了標題(「Content-type:text/xml」);並且工作。 – user1970475