Possible Duplicate:
how to parse xml file using google map api
I have the following code which returns xml output sucessfully but their is problem with parsing xml and displaying output on the map.when i look the request and response output on firebug i am sucessfully getting xml file but problem with parsing that particular file using google map api .
function searchLocationsNear() {
var radius = document.getElementById('radiusSelect').value;
var searchUrl = "http://localhost:1894/blockseek8-9-2010/Block3.xml"; //reference for xml file stored in application folder
GDownloadUrl(searchUrl, function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName('marker');
map.clearOverlays();
var sidebar = document.getElementById('sidebar');
sidebar.innerHTML = '';
alert(markers.length);
if (markers.length == 0) {
sidebar.innerHTML = 'No results found.';
map.setCenter(new GLatLng(40, -100), 4);
return;
}
var bounds = new GLatLngBounds();
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute('name');
var address = markers[i].getAttribute('address');
var distance = parseFloat(markers[i].getAttribute('distance'));
var point = new GLatLng(parseFloat(markers[i]
.getAttribute('lat')), parseFloat(markers[i]
.getAttribute('lng')));
var imagepath = markers[i].getAttribute('imagepath');
var marker = createMarker(point, name, address, imagepath);
map.addOverlay(marker);
var sidebarEntry = createSidebarEntry(marker, name, address,
distance, imagepath);
sidebar.appendChild(sidebarEntry);
bounds.extend(point);
}
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
});
}