0
....
<Folder>
    <name>FooName</name>
    <Placemark id="3">
        <description><![CDATA[ Foo HTML stuff ]]></description>
        <TimeStamp>
            <when>2011-11-01T09:01:11Z</when>
        </TimeStamp>
        <Point>
            <altitudeMode>absolute</altitudeMode>
            <coordinates>39.1470525,-76.5148821,777.111</coordinates>
        </Point>
    </Placemark>
</Folder>
...

Here is my code:

   PullParser parser = new PullParser( new KMLConfiguration(), FileUtils.openInputStream(new File("foo.kml")), SimpleFeature.class);

    SimpleFeature simpleFeature (SimpleFeature)parser.parse();
    Object obj = simpleFeature.getAttribute("TimeStamp");
    //obj is null..does not parse TimeStamp?..
    Object objPoint = simpleFeature.getDefaultGeometry();
    //this works fine...objPoint is an instance of Point...

    Object objDescription = simpleFeature.getAttribute("description");
    //this works fine, objDescription is an instance of String with the   CDATA data there.             

for example

simpleFeature.getAttribute("description"), will return a String of the content of the description which in the above KML is CDATA stuff...

simpleFeature.getAttribute("TimeStamp")

, however TimeStamp is null :( ..I would have expected a Timestamp or a list of Date(s)?

is there a way to get the TimeStamp from the above KML with geotools without custom parsing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.