doubutao6216 2013-11-06 15:12
浏览 41

用html camp解析mysql到xml

I'm trying to parse data from mysql to xml. To use it for create markers on a Google Map. But I have a problem. When in the column of mysql I use html like it crashes.

Mi code is:

$query = "SELECT * FROM mapas";
$resultado = mysql_query($query);
$row = mysql_fetch_assoc($resultado);


header("Content-Type: text/xml;charset=iso-8859-1");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<markers xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
do{
echo'<marker id="'.$row["id"].'" lat="'.$row["lat"].'" lng="'.$row["lng"].'" title="'.$row["title"].'" content="'.$row["content"].'" icon="'.$row["icon"].'"/>';
}while($row=mysql_fetch_assoc($resultado));
echo '</markers>';

?>

When I access to the page to see the xml the problem shown is:

This page contains the following errors:

error on line 1 at column 137: Unescaped '<' not allowed in attributes values Below is a rendering of the page up to the first error.

In Mysql the structure of the column is: Type: Text, uf8-general-ci....

If I use just text I have no problem at all. ¿Could you help me?

Thank you!

  • 写回答

1条回答 默认 最新

  • doumian3780 2013-11-06 15:17
    关注

    try changing

    echo'<marker id="'.$row["id"].'" lat="'.$row["lat"].'" lng="'.$row["lng"].'" title="'.$row["title"].'" content="'.$row["content"].'" icon="'.$row["icon"].'"/>';
    

    to

    echo'<marker id="'.$row["id"].'" lat="'.$row["lat"].'" lng="'.$row["lng"].'" title="'.$row["title"].'" content="'.$row["content"].'" icon="'.$row["icon"].'"></marker>';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算