[OpenLayers-Users] KML
EGoss at Geosyntec.com
EGoss at Geosyntec.com
Thu Feb 25 10:13:09 EST 2010
Does anyone know why the line(s) below would return 'null' or null?
xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;
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;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100225/b6e30aaa/attachment.html
More information about the Users
mailing list