Hi,
I have a problem with JAK.
I have to parse a kml file to modify a description of a Placemark; in the description I have a CDATA field with Html code.
I parse the file successfully and I replace the description of the Placemark but, when I marshal the kml, the file contains wrong chars.
Is a problem of the api or I make some mistakes in the code?
The java code:
String description = "<![CDATA[Timestamp last value: 11/07/2012....]]>"
Kml kml = Kml.unmarshal(new File(path));
Document document = (Document) kml.getFeature(); //Get the document features
Iterator<Feature> iterator = document.getFeature().iterator(); //Create an iterator for the placemark
Feature feature = null;
while (iterator.hasNext()) {
feature = iterator.next();
if (feature.getName().compareTo("elementToFind") == 0) {
break;
}
}
feature.setDescription(description);
kml.marshal(new File(path));
---------------
Original kml file
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<name>Mappa Idrica</name>
<Placemark>
<name>elementToFind</name>
<description><![CDATA[ Timestamp last value: 2013-15-06 ]]></description>
<Point>
<coordinates>12.753721,38.173355,0.000000</coordinates>
</Point>
</Placemark>
---------------
Modified kml file
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<name>Mappa Idrica</name>
<Placemark>
<name>elementToFind</name>
<description><![CDATA[Timestamp last value: 11/07/2013 ]]>
</description>
<styleUrl>#noiseStyle1</styleUrl>
<Point>
<coordinates>12.753721,38.173355</coordinates>
</Point>
</Placemark>
Thanks!!!