In can't parse the kml to my GE, whats wrong with my code?

I'm stuck at this for 2 weeks and tried myself to do many others ways,

Any help will be welcome,

Rafael Jesus

google\_earth.jsp 

```
var ge;  

google.load("earth", "1");  

function init() {  
    google.earth.createInstance('map3d', initCB, failureCB);  
    window.scroll(0, 10000);  
}  

function initCB(instance) {  
    ge = instance;  
    ge.getWindow().setVisibility(true);  

    // add a navigation control  
    ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);  

    // add some layers  
    ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);  
    ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);  

    // directs the exact location of the placemark  
    var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);  
    lookAt.setLatitude(-15.26108113514467);  
    lookAt.setLongitude(-57.77290131815782);  
    lookAt.setRange(8007066.726300671);  

    ge.getView().setAbstractView(lookAt);  
    ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, false);  

    var kmlString = showPics();  
    // I put a alert in here and show in a window the value "undefined"  
    var kmlObject = ge.parseKml( kmlString );  
    ge.getFeatures().appendChild(kmlObject);  

```

} 

```
// dwr function that brings the kml with his values  
            // for now it is in hard coded, just for tests!!  
    function showPics() {  
        PainelEarthAjax.geraFotosObra({  
            callback : function(kmlString) {  
                            // I put a alert function in here, and it has openned a window  
                            // with the entire kmlString brought from the java method geraFotosObra().  
                    return kmlString;  
            }  
        });  
    }  

function failureCB(errorCode) {  

}    
google.setOnLoadCallback(init); 

```

geraFotosObra.java 

```
public String geraFotosObra () throws Exception {  
    try {  
        return new KMLGenerator().getKMLFromObra();  
    } catch (Exception e) {  
        log.error(e.getLocalizedMessage(), e);  
        return null;  
    }  
}  

```

KMLGenerator.java 

```
public static String getKMLFromObra () {  
    StringBuffer sb = new StringBuffer();  
    sb.append("<?xml version='1.0' encoding='UTF-8'?>");  
    sb.append("<kml xmlns='http://www.opengis.net/kml/2.2' ");  

    sb.append("<Document>");  
    sb.append("<name>ConstruMobil</name>");  

    sb.append("<Style id='defaultStyles'>");  
    sb.append("<IconStyle>");  
    sb.append("<Icon>");  
    sb.append("<href>" + "http://maps.google.com/mapfiles/kml/pal4/icon38.png" + "</href>");  
    sb.append("</Icon>");  
    sb.append("</IconStyle>");  
    sb.append("</Style>");  
    sb.append("</Style>");  

    sb.append("<Placemark>");  
    sb.append("<name>" + "Some name" + "</name>");  
    sb.append("<styleUrl>" + "#defaultStyles"+ "</styleUrl>");  
    sb.append("<altitudeMode>" + "relativeToGround" + "</altitudeMode>");  

    sb.append("<Location>");  
    sb.append("<longitude>" + -122.3599987260313 + "</longitude>");  
    sb.append("<latitude>" + 47.62949781133496 + "</latitude>");  
    sb.append("<altitude>"+ 15.49615401024533 + "</altitude>");  
    sb.append("</Location>");  

    sb.append("<Link>");  
    sb.append("<href>" + "http://localhost:8080/myCompany/lib/img/dubai.jpg" + "</href>");  
    sb.append("</Link>");  
    sb.append("</Model>");  
    sb.append("</Placemark>");  

    sb.append("</Document>");  
    sb.append("</kml>");  

    return sb.toString();  
}  

```