KML file format or minimum requirements

北城余情 提交于 2019-12-24 23:19:12

问题


Having minimal experience with XML, and none whatsoever with KML, I try to find something along the lines of what a program expects when reading a KML file.

I'm writing some software to generate a KML file, but when I try to open said file in Google Earth, I get this error:

Open of file "C:/blahblah/myFile.kml" failed: Parse error at line 21, column 0:

junk after document element

I have reduced myFile down to the following, with the same error.

<? xml version="1.0" encoding="utf-8"?>
<Placemark>
</Placemark>
<Placemark>
</Placemark>

Am I missing something some required element? Is there a section of the standard I may have missed that deals with how to properly form a KML file?


回答1:


KML is an XML file and as such can be validated to the KML XML Schema. One simple tool to validate KML files is the XML Validator. Further details and examples of KML are found in KML Best Practice and the KML Reference.

Multiple placemarks require a Document or Folder parent element. Such a KML file would be structured as the following:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <Placemark>
        </Placemark>
        <Placemark>
        </Placemark>
    </Document>
</kml>


来源:https://stackoverflow.com/questions/48123721/kml-file-format-or-minimum-requirements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!