这是我的代码。
<?php
$this->load->database();
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
$query = $this->db->get('comboTable');
$query = $query->result_array();
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
foreach($query as $row)
{
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row['restaurantName']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
}
echo $dom->saveXML();
&GT;
它给了我一个错误,即文档末尾有额外的东西。但是当我测试输出时,它看起来是正确的。任何想法?