【发布时间】:2017-01-25 04:54:43
【问题描述】:
我在加载页面时收到此错误,搜索 Google 时没有运气..
XML 解析错误:格式不正确
位置://网址
第 7 行,第 103 列:
(这只是代码的一部分,非常简化。)
<?php
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
echo <<<html
<html>
<head>
<title>Map Project</title>
<meta charset="utf-8">
<script src=http://maps.googleapis.com/maps/api/js?key=AIzaSyDX319H1v1c6xxiVZm-PTuADCnKLZo&sensor=false"></script>
</head>
<body onload="localStorage.clear();">
html;
// DB Connection codes goes here..
$query= "SELECT * FROM `mapx`";
$result = mysqli_query($dbc,$query);
if (!$result) {
echo 'ERROR!';
}
header("Content-type: text/xml");
echo '<markers>';
while ($row = @mysqli_fetch_assoc($result)){
echo '<marker ';
echo 'name="' . parseToXML($row['user']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo '/>';
}
echo '</markers>';
echo <<<html
//other parts..
</body>
</html>
html;
?>
错误指向的部分:
sensor=[HERE]假
【问题讨论】: