title: Uncaught TypeError: Cannot read property 'responseXML' of undefined
body: <p>I'm attempting to develop an website using JavaScript,</p>
  
  <p>The goal, is to get data of a xml file, and convert them into vars.</p>
  
  <pre><code>var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
          initMap(this);
      }
  };
  
  xhttp.open("GET", "https://applications002.brest-metropole.fr/WIPOD01/Transport/REST/getGeolocatedVehiclesPosition?format=xml&amp;route_id=1&amp;trip_headsign=Fort%20Montbarey", true);
  
  xhttp.send();
  
  function initMap(xml) {
      var xlat, xlon, i, xmlDoc;
      xmlDoc = xml.responseXML;
      xlat = xmlDoc.getElementsByTagName('Lat');
      xlon = xmlDoc.getElementsByTagName('Lon');
      /*
      xlat = xml.responseXML.getElementsByTagName('lat');
      xlon = xml.responseXML.getElementsByTagName('lon');
      */
      for (i = 0; i &lt; xlat.length; i++) {
          var latcode = xlat[i].childNodes[0].nodeValue;
          var loncode = xlon[i].childNodes[0].nodeValue;
          //var myLatLng = "{lat: " + latcode + ", lng: " + loncode +"}";
          //var myLatLng = {lat: latcode, lng: loncode};
          var marker = new google.maps.Marker({
              position: new google.maps.LatLng(latcode, loncode),
              map: map,
          });
      }
      [...]
  }
  </code></pre>
  
  <p>but I obtain this code error : <code>Uncaught TypeError: Cannot read property 'responseXML' of undefined</code> @ -> <code>xmlDoc = xml.responseXML;</code></p>
  
  <p>I've already tried to remplace <code>xmlDoc = xml.responseXML;</code> by <code>xmlDoc = this.responseXML;</code></p>
  
  <p>but I obtain the some error for getElementByTagName: <code>Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined</code></p>
  
  <p>Thanks for Help !
  Jacques</p>
  
  <p>EDIT: Code source: <a href="https://docs.google.com/document/d/1iuyMgS0dmKUitKoRbUJZ6-LRVaACjOIL_qnXwBJ_8-Y/edit?usp=sharing" rel="nofollow noreferrer">Google Doc</a> Yes the live demo works for me, I'm using Google Chrome</p>