调试KML文件 [英] Debugging KML file

查看:69
本文介绍了调试KML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document> <Placemark> <Name>Test Name</Name> <Description><b>Project Information</b><br><ul><li>Project Name: Test Name</li><li>Project Number: Test Number</li><li>Project Location:  Test Location</li><li>System: Test System</li></ul><br><b>Project Team</b><br><br><ul><li>Regional Manager: Mem 1</li><li>Project Manager: Mem 2</li></ul><br>YouTube Video URL: <a href="http://youtu.be/U9EYP9GIe2k"><br>Picassa Album URL: <a href="www.picassa.com"><br></Description> <Point> <Coordinates>30,-125</Coordinates>,0 </Point> </Placemark> </Document> </kml>

这是我的自定义Excel宏正在生成的内容(我是编程新手,所以如果发现一些大问题,请对我轻松一点).当我尝试使用Google Earth打开KML文件时,收到以下消息:打开文件"文件路径"失败:第2行第454列的解析错误:标记不匹配.这与/Description标签相关...此标签有什么问题?我将其与相应的Description标签相匹配.

This is what my custom Excel macro is generating (I'm new to programming, so take it easy on me if you notice something big). When I attempt to open the KML file with Google Earth, I get the following message: Open of file "file path" failed: Parse error at line 2, column 454: mismatched tag. This correlates to the /Description tag... What is wrong with this tag? I matches up with it's corresponding Description tag.

推荐答案

您可以使用多种技术来调试和修复损坏的KML文件.

There are a handful of techniques you can apply to debug and repair a corrupt KML file.

基本上,验证KML文件的最快方法是首先使用网络浏览器. KML是XML文件,因此首先您可以测试它是否是格式正确的XML文件,这是使其成为有效KML文件的先决条件.只需重命名KML文件并添加一个.xml文件扩展名,然后将该文件拖到网络浏览器(Firefox,Chrome等)上即可对其进行验证. 在此处查看详细示例.

Basically, the quickest way to validate a KML file is first using your web browser. KML is an XML file so first you can test if it's a well-formed XML file, which is a prerequisite to it being a valid KML file. Simply rename the KML file adding an .xml file extension then drag the file onto a web browser (Firefox, Chrome, etc.) to validate it. See detailed example here.

一旦发现并修复了这些错误,则可以尝试使用KML验证程序,该验证程序根据OGC KML规范和相关的XML Schema来检查文件是否为有效的KML. Galdos KML验证器或独立的命令行

Once those errors are found and fixed then you can try a KML validator that checks if the file is valid KML with respect to the OGC KML Specification and associated XML Schema such as the Galdos KML validator or the standalone command-line XmlValidator tool.

在您的示例中,如果通过简单的XML SAX解析器运行它,则会显示:元素类型"br"必须由第455列中匹配的结束标记"</br>"终止.

In your example, if you run it through a simple XML SAX parser it shows: element type "br" must be terminated by the matching end-tag "</br>" at column 455.

错误是<description>元素具有HTML标记,但没有被 CDATA 块转义(CDATA是XML标准的一部分).要解决此问题,您需要像这样重新格式化您的KML:

Error being that <description> element has HTML markup but isn't escaped with a CDATA block (CDATA is part of the XML standard). To fix this you need to reformat your KML like this:

  <description>
      <![CDATA[
          <b>Project Information</b>
          ...
          <br>
      ]]>
  </description>

此外,该元素具有错误的名称(描述与描述). KML区分大小写.

Also, the element has the wrong name (Description vs description). KML is case-sensitive.

可以在此处找到更多调试KML文件的提示.

More tips to debug KML files can be found here.

这篇关于调试KML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆