Google Maps API V3 Marker not showing due to undefined variable-Record and share programming errors

I am having difficult getting my markers to show with the Google Maps V3 API.

I get the below error when I load the page –

TypeError: xml is undefined

var markers = xml.documentElement.getElementsByTagName(“marker”);

I’ve tried declaring the xml variable in a few different ways but to no avail.

Any help greatly appreciated.

function load() {
  map = new google.maps.Map(document.getElementById("map_canvas"), {
    center: new google.maps.LatLng(37.765558,-122.450867),
    zoom: 11,
    mapTypeId: 'roadmap'
  });
  var infoWindow = new google.maps.InfoWindow;

  // Change this depending on the name of your PHP file
  downloadUrl("phpsearch.php", function(data) {
    xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");//

Originally posted 2013-08-31 06:21:05.