[OpenLayers-Users] KML

Christopher Schmidt crschmidt at metacarta.com
Thu Feb 25 11:10:48 EST 2010


On Thu, Feb 25, 2010 at 10:13:09AM -0500, EGoss at Geosyntec.com wrote:
> Does anyone know why the line(s) below would return 'null' or null?
> 
> xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;

... Without your KML file? How could we know?

-- Chris

> Thanks!
> 
> ///////////////////////PARSING OUT KML INFORMATION//////////////////////////////////////
> 
>                 OpenLayers.loadURL(kmlLayer.url, '', this, setKML);
> 
> /////////////////////////////////////////////////////////////////////////////////////////////
> 
> function setKML(response) {
>     if (response.responseText.indexOf('no results') == -1) {
>         alert(response.responseText);
>         var xmlDoc = response.responseXML.documentElement;
>         //var xmlDoc = response.responseText;
> 
>      var name =
>        xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;
>      alert(name);
> 
>      var description =
>        xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;
>      alert(description);
> 
>      var coordinates =
>        xmlDoc.getElementsByTagName("coordinates")[0].childNodes[0].nodeValue;
>      alert(coordinates);
> 
>      var content = '<table border="1" cellpadding="1" cellspacing="1">';
>      content += '<tr><th>Name</th><th>Description</th><th>Coordinates</th></tr>';
>      content += '<tr><td>'+name+'</td><td>'+description+'</td><td>'+coordinates+'</td></tr>';
>      content += '</table>';
> 
>      document.getElementById('content').innerHTML = content;
> 
>    }
> }
> 
> 

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list