gpsbabel
gpsbabel copied to clipboard
Namespaces are not considered when parsing kml
It seems that namespaces are not taken into account when parsing kml files.
This file, with http://www.opengis.net/kml/2.2 as the default namespace, can correctly be converted to gpx format:
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<TimeSpan>
<begin>2019-11-28T09:10:47.973Z</begin>
<end>2019-11-28T09:18:30.731Z</end>
</TimeSpan>
<LineString>
<coordinates>5.6503587,58.726241099999996,0 5.69573010002664,58.72640951793773,0</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
This file, which should be entirely equivalent, other than the namespace being called ns instead of being the default namespace, cannot be converted to gpx format:
<ns:kml xmlns:ns="http://www.opengis.net/kml/2.2">
<ns:Document>
<ns:Placemark>
<ns:TimeSpan>
<ns:begin>2019-11-28T09:10:47.973Z</ns:begin>
<ns:end>2019-11-28T09:18:30.731Z</ns:end>
</ns:TimeSpan>
<ns:LineString>
<ns:coordinates>5.6503587,58.726241099999996,0 5.69573010002664,58.72640951793773,0</ns:coordinates>
</ns:LineString>
</ns:Placemark>
</ns:Document>
</ns:kml>
GPSBabel reports "Translation successful", but the converted file looks like this:
<gpx version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
<time>2020-02-17T12:34:46.930Z</time>
</gpx>
This file, which is not valid kml, since it does not use namespaces, can correctly be converted to gpx format:
<kml>
<Document>
<Placemark>
<TimeSpan>
<begin>2019-11-28T09:10:47.973Z</begin>
<end>2019-11-28T09:18:30.731Z</end>
</TimeSpan>
<LineString>
<coordinates>5.6503587,58.726241099999996,0 5.69573010002664,58.72640951793773,0</coordinates>
</LineString>
</Placemark>
</Document>
</kml>