I'm writing some code to output a KML file, with certain application-specific info stored in the ExtendedData nodes. As an easy way to debug the validity of my KML, I'm using Google Earth with the "Show prompts for all errors" option enabled (http://screencast.com/t/UDkJc6Nv5G4).
I'm trying to write the ExtendedData as untyped arbitrary tags, as documented in the KML reference under namespace_prefix:other (see: https://developers.google.com/kml/documentation/kmlreference?csw=1#extendeddata) The problem is, even if I replicate their sample code precisely, Google Earth complains about an unknown element: http://screencast.com/t/bCMgaDiDYdWt.
Here's the complete KML:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Sample KML.kml</name>
<Placemark>
<name>Test KML</name>
<Point>
<coordinates>-118.405022621,33.943893977,0</coordinates>
</Point>
<ExtendedData xmlns:prefix="camp">
<camp:number>14</camp:number>
<camp:parkingSpaces>2</camp:parkingSpaces>
<camp:tentSites>4</camp:tentSites>
</ExtendedData>
</Placemark>
</Document>
</kml>
I'm aware that there are alternative ways to include application-specific data (i.e. <Data>, <SchemaData>, etc) - but for this question, I'm interested in figuring out why Google's own software reports this as invalid, when it comes straight from their own example. Have I left something else out of the KML, or am I misinterpreting the docs?
The example is correct. However, when "Show prompts for all errors" option is enabled in Google Earth, arbitrary namespaces for extended data is always displayed as an error.
This was reported as an issue in 2009 but has not been fixed. https://code.google.com/p/earth-issues/issues/detail?id=438
Using arbitrary namespaces for extended data is a valid usage of KML as defined by the KML 2.2 specification so it's not really an error. Google Earth is just reporting that it doesn't know what to do with that element which is correct in the sense that when adding arbitrary XML data to a Feature Google Earth preserves this data but does not process it. It should not be reported as an error.
Here is an example using a real namespace for extended data in KML. This example uses Dublin Core namespace for metadata to KML: https://productforums.google.com/d/msg/maps/8pbTmPIbj18/J_w2mjRWyQoJ
If want to validate arbitrary namespaces in your KML you can't use Google Earth's validation. You need a XML Schema-aware validator such as the standalone comment-line tool XmlValidate. Further discussion of validation in Google Earth can be found here.