2017-01-25 64 views
0

加載頁面時,我得到這個錯誤,在谷歌搜索沒有運氣..PHP:XML解析錯誤:沒有很好地形成

XML Parsing Error: not well-formed

Location: //URL

Line Number 7, Column 103:

(這只是部分代碼,非常simplized。)

<?php 

function parseToXML($htmlStr) 
{ 
    $xmlStr=str_replace('<','&lt;',$htmlStr); 
    $xmlStr=str_replace('>','&gt;',$xmlStr); 
    $xmlStr=str_replace('"','&quot;',$xmlStr); 
    $xmlStr=str_replace("'",'&#39;',$xmlStr); 
    $xmlStr=str_replace("&",'&amp;',$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]false

回答

0

我看到你的代碼,你會錯過在這裏=和echo <<<htmlhtml; SCRIPT SRC是什麼,但錯誤代碼應該是這樣的

 <?php 

    function parseToXML($htmlStr) 
    { 
     $xmlStr=str_replace('<','&lt;',$htmlStr); 
     $xmlStr=str_replace('>','&gt;',$xmlStr); 
     $xmlStr=str_replace('"','&quot;',$xmlStr); 
     $xmlStr=str_replace("'",'&#39;',$xmlStr); 
     $xmlStr=str_replace("&",'&amp;',$xmlStr); 
     return $xmlStr; 
    } 
    ?> 
    <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();"> 

    <?php 
    // 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>'; 

    ?> 

    //other parts.. 

    </body> 
    </html> 

感謝

+0

編輯,並在同一個地方/同樣的錯誤仍然指向。 –

+0

我會測試這個。謝謝。 –

+0

好的沒問題 –

相關問題