XML错误验证器

时间:2013-12-27 17:43:13

标签: xml

我对XML文件有疑问,我无法解决它。请你帮助我好吗? XML验证器显示:“第2列第15969行的错误:文档末尾的额外内容。”部分问题代码:

<?xml version="1.0" encoding="UTF-8"?>
<results trackingurl="GPS">
<results>
    <object id="535">
     <title><![CDATA[Title blablabla...]]></title>
         <thumbnail><![CDATA[http://vsohbrno.chudst.cz/poi_obrazek.png]]></thumbnail>
         <icon><![CDATA[http://vsohbrno.chudst.cz/poi_obrazek.png]]></icon>
         <location>
         <lat>50.9838275000</lat>
         <lon>14.2881458000</lon>
         <alt>0</alt>
         </location>
         <popup>
         <description><![CDATA[Description blablabla...]]></description>
         <buttons>
             <button id="url" name="Website"><![CDATA[http://www.leag.cz]]></button>
         </buttons>
         </popup>
    </object>
</results>

我使用php生成代码:

while ($radek = mysql_fetch_array($results))
{

$text = '  
 <object id="'. $radek['id'] .'">
  <title><![CDATA['. $radek['title'] .']]></title>
    <thumbnail><![CDATA['. $radek['imageURL'] .']]></thumbnail>
    <icon><![CDATA['. $radek['imageURL'] .']]></icon>
    <location>
        <lat>'. $radek['lat'] .'</lat>
        <lon>'. $radek['lon'] .'</lon>
        <alt>0</alt>
    </location>
    <popup>
        <description><![CDATA['. $radek['line2'] . ' ' .  $radek['attribution'] .']]></description>
        <buttons>
            <button id="url" name="Website"><![CDATA[http://www.leag.cz]]></button>
    </buttons>
    </popup>
 </object>
';                             

$file= fopen("poi_junaio.xml", "a+");
fwrite($file, $text);
fclose($file);
}
$end= '</results>';
$file= fopen("poi_junaio.xml", "a+");
fwrite($file, $end);
fclose($file);

感谢任何解决方案!

1 个答案:

答案 0 :(得分:0)

<results trackingurl="GPS">
  <results>
    ...
  </results>
</results>

“结果”的秒结束标记丢失,或者您不需要第二个“结果”开始标记