title: Cannot read property 'getElementsByTagName' of null, what is happening?
body: <p>My problem seems to lie somewhere in between the subfunction calling of LoadXML. It seems that the xml data becomes null for some weird reason, and I have no idea how to fix that. Stackexchange seemed to have loads of similar questions but many were unanswered or the answer they had did not help my case.</p>
  
  <pre><code>function load() {
      var xmlhttp;
      xmlhttp = new XMLHttpRequest();
      var idname = document.getElementById("name").value;
      xmlhttp.onreadystatechange = function () {
          if (this.readyState == 4 &amp;&amp; this.status == 200) {
              console.log(this); //it obtains it here...
              LoadXML(this, idname);
          }
      };
      xmlhttp.open("GET", "helper_database.xml", false);
      xmlhttp.overrideMimeType('text/xml');
      xmlhttp.send();
  }
  
  function LoadXML(xml, name) {
      var x, i, xmlDoc, nametxt, areEqual;
      xmlDoc = xml.responseXML;
      nametxt = name;
      console.log("HERE \n" + xmlDoc); //...but it becomes null.
      x = xmlDoc.getElementsByTagName("name"); //this returns the error of "Cannot read property 'getElementsByTagName' of null"
      console.log("muuttujan x eka: " + x[0]);
      for (i = 0; i &lt; x.length; i++) {
          if (areEqual = xmlDoc.getElementsByTagName("name").toUpperCase() === nametxt.toUpperCase()) {
              document.getElementById("ComFocus").value = x[i];
          }
      }
  }
  </code></pre>
  
  <p>Here is the helper_database.xml</p>
  
  <pre><code>&lt;Character&gt;
      &lt;name&gt;test&lt;/name&gt;
      &lt;stats&gt;
          &lt;Com&gt;1&lt;/Com&gt;
          &lt;Con&gt;2&lt;/Con&gt;
          &lt;Cun&gt;3&lt;/Cun&gt;
          &lt;Dex&gt;4&lt;/Dex&gt;
          &lt;Mag&gt;5&lt;/Mag&gt;
          &lt;Per&gt;6&lt;/Per&gt;
          &lt;Str&gt;7&lt;/Str&gt;
          &lt;Wil&gt;8&lt;/wil&gt;
      &lt;/stats&gt;
  &lt;/Character&gt;
  </code></pre>