My KML File has the following format:
<Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#seb">
<SimpleData name="PR0">CORS</SimpleData>
<SimpleData name="PR1">BRB</SimpleData>
<SimpleData name="PR2">F15</SimpleData>
</SchemaData></ExtendedData>
<MultiGeometry><Polygon><altitudeMode>clampToGround</altitudeMode><outerBoundaryIs><LinearRing><altitudeMode>clampToGround</altitudeMode><coordinates>71.0035714700001,38.4757616580001 71.0567352510001,38.398144523 71.1035044220001,38.422803406000138.4764993150001 71.0035714700001,38.4757616580001</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>
I want to be able to access the the extended data fields from the kml which I will be using for further processing and indexing the polygons for later use and searching.
As this post states, the variables can be access from placemark.vars.val but I could not get this since vars is undefined.
Replying to geocodezip reply above...
You approach works but the problem is the kml is produced frequently. Making the changes you mentioned might be a bit difficult because of the content of the <SimpleData>
tag which contains the value as text where the expected format is <Data><value></value></Data>
.
Best way would be to create a php or any program that parse the kml and make the changes. I decided to edit the GeoXML3.js parser to look for SimpleData instead of Data tags at line number 639
var dataNodes = getElementsByTagName(extDataNodes[0], 'Data');