KML file format or minimum requirements

2019-08-25 03:01发布

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条回答
Bombasti
2楼-- · 2019-08-25 03:50

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>
查看更多
登录 后发表回答