I have a program that gets a csv and conver it into a kmz that can be opened in Google Earth
The problem is that one of the inputs is the Description that has a table inside
So I have this:
@Element(name = "Description")
private String description;
And I create the html structure and add the element
String htmlTable = "<table border='1' width='300'><tr><td>" +
contenidoProcesado[1] + "</td></tr></table>";
String description = "<![CDATA[<div>" + htmlTable + "</div>]]>";
placemark.setDescription(description);
Later I use a Serializer with a list of all my entries in the csv as placemarks and create this kmz with a kml inside with all the data.
try {
Serializer serializer = new Persister();
Document kml = new Document(placemarks);
try {
// Read in the KML file
File kmlFile = new File(filePath.substring(0, filePath.lastIndexOf(".")) + ".kml" );
String kmlFileName = kmlFile.getName();
FileInputStream fis = new FileInputStream(kmlFile);
byte[] kmlBytes = new byte[(int) kmlFile.length()];
fis.read(kmlBytes);
fis.close();
// Create the KMZ file
File kmzFile = new File(filePath.substring(0, filePath.lastIndexOf(".")) + ".kmz" );
FileOutputStream fos = new FileOutputStream(kmzFile);
ZipOutputStream zos = new ZipOutputStream(fos);
// Add the KML file to the KMZ archive
ZipEntry kmlEntry = new ZipEntry(kmlFileName);
zos.putNextEntry(kmlEntry);
zos.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n").getBytes());
zos.write(("<kml xmlns=\"http://www.opengis.net/kml/2.2\">" + "\n").getBytes());
serializer.write(kml, zos); // write KML data directly to the KMZ file
zos.write("</kml>".getBytes()); // add closing </kml> tag to the KMZ file
zos.closeEntry();
I can Open the mz generated in Google Earth but the description is not appearing and if I open the kml it's like this:
<Description><div><table border=&apos;1&apos; width=&apos;300&apos;><tr><td>LAM450520</td></tr></table></div></Description>
It does not have an html structure because it converted the "", < and > into special quotes so Google Earth cannot display this description.
Could you guide me a little to finally have the structure unaltered, so I can read it from Google Earth please?