小编I2B*_*eve的帖子

“XML 解析错误:文档元素后的垃圾”

大家好,我试图用动态的位置从数据库中检索,我下面显示谷歌地图上phpsqlajax_v3 developers.google.com/maps/articles。我创建的数据库和表看起来像这样

运输公共表

transportpublicid int 11 AUTOINCREMENT

运输类型 varchar 60

costPerKm 十进制(7,2)

地址 varchar 800

电话号码 int 10

webLink varchar 300

描述 varchar 800

纬度双(10,6)

lng double(10,6)


生成Xml.php

 <?php

          require("db_connection.php");


          function parseToXML($htmlStr) 
          { 
              $xmlStr=str_replace('<','&lt;',$htmlStr); 
              $xmlStr=str_replace('>','&gt;',$xmlStr); 
              $xmlStr=str_replace('"','&quot;',$xmlStr); 
              $xmlStr=str_replace("'",'&#39;',$xmlStr); // line 11  
              $xmlStr=str_replace("&",'&amp;',$xmlStr); 
              return $xmlStr; 
          } 

          // Select all the rows in the markers table
          $query = "SELECT transportType,costPerKm,address,teleNo,webLink,lat,lng FROM transportpublic";

          $result = mysql_query($query);
          if (!$result) 
          {
            die('Invalid query: ' . mysql_error());
          }

          header("Content-type: text/xml");

          // Start XML file, echo …
Run Code Online (Sandbox Code Playgroud)

php google-maps-api-3 xml-parsing

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

google-maps-api-3 ×1

php ×1

xml-parsing ×1