First:
This should not be inside the for loop:
google.maps.event.addDomListener(window, 'load', initialize);
Second:
var infowindow = new google.maps.InfoWindow({
Javascript doesn't have scope in blocks, so this declaration is inside a containing function. Take a look at this:
http://www.sitepoint.com/demystifying-javascript-variable-scope-hoisting/[
^]
and i suggest you learn about closures too.
So, for this to work you could do something like:
for (i=0;i<x.length;i++)
{
(function (i) {
xx=x[i].getElementsByTagName("Lat");
out1=xx[i].firstChild.nodeValue;
xx=x[i].getElementsByTagName("long");
out2=xx[i].firstChild.nodeValue;
xx=x[i].getElementsByTagName("Name");
out3=xx[i].firstChild.nodeValue;
xx=x[i].getElementsByTagName("Phoneno");
out4=xx[i].firstChild.nodeValue;
var marker = new google.maps.Marker({
position: { lat:parseFloat(out1), lng: parseFloat(out2)},
map: map
}),
infowindow = new google.maps.InfoWindow({
content: '
Donor Location:' + marker.getPosition() +'Name'+' '+out3+'Phoneno'+out4+' '+ '
'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}(i))
}
------------------------------EDIT----------------------------------------------
There's something i didn't noticed before, but you are not using the var "i" when setting values on out1, out2, out3, out4 vars. You always get it from the first element on array.