dougehe2022 2019-06-20 06:19
浏览 23

为谷歌地图煽动创建XML文件

i am trying to create XML file but got error. enter image description here

i want XML file out display on page or create XML into a path. but i got these error.

<?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;
}


    $host = ""; // hostname
    $username = ''; // username
    $psswrd = ''; // pass
    $db = ''; // database
    $dbc = mysqli_connect($host, $username, $psswrd, $db);

    if(!mysqli_connect_errno() ) {
        echo 'sueccess'; } else { 
        die("Database failed: " . 
        mysqli_connect_error() .
        " ( " . mysqli_connect_errno() . " )"
        );

    }


$query = "SELECT * FROM pace_hse_flra_hazards_content WHERE lat !='' AND lng !=''";

 $result = mysqli_query($dbc, $query);
if (!$result) {
  die('Invalid query: ' . mysqli_error());
}

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

// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
  // Add to XML document node
  echo '<marker ';
  echo 'id="' . $row['hazardsId'] . '" ';
 // echo 'name="' . parseToXML($row['name']) . '" ';
  echo 'address="' . parseToXML($row['geoLocation']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  //echo 'type="' . $row['type'] . '" ';
  echo '/>';
  $ind = $ind + 1;
}
// End XML file
echo '</markers>';

?>

This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题