title: Cannot read property 'getElementsByTagName' of null
body: <p>Please pardon my confusion as I stumble through this, I am new to javascript and this kind of thing. Please also pardon me if my code is garbage, because it is a combination of examples I found, and things I figured out (and didn't figure out)!</p>
  
  <p>I am trying to run this html file in Open Broadcaster Software:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="css/stylesheet_twitter1.css" type="text/css" charset="utf-8"&gt;
      &lt;script src="js/jquery-2.0.2.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
      &lt;script src="js/jstween-1.1.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
      &lt;script src="js/countries.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
              var timestampOld;
              var timestamp;
              var mText4;
  
              var xmlDoc;
  
              var xhr = new XMLHttpRequest();
  
              var animating = false;
              var doUpdate = false;
  
              function init() {
  
                  xhr.overrideMimeType('text/xml');
  
                  var timeout = this.window.setInterval(function() {
                      pollHandler();
                  }, 250);
  
                  $('#mText4').html('');
                  $('#board').tween({
                     top:{
                        start: '80',
                        stop: '0',
                        units: 'px',
                        time: 0,
                        duration: 0.8,
                        effect:'easeOut'
                     }
                  });
  
                  $.play();
              }
  
  
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="init()"&gt;
  
      &lt;script type="text/javascript"&gt;
              function pollHandler()
              {
                loadData();
                if (timestamp != timestampOld) {
                    doUpdate = true;
                }
                if (!animating &amp;&amp; doUpdate) {
                    updateBoard();
                }
              }
  
              function loadData() {
                  xhr.open('GET', 'streamcontrol.xml');
                  xhr.send();
                  xhr.onreadystatechange = function(){
                          xmlDoc = xhr.responseXML;
  
  
                          mText4 = getValueFromTag(xmlDoc,'mText4');                      
                          timestampOld = timestamp;
                          timestamp = getValueFromTag(xmlDoc,'timestamp');
  
                  }
              }
  
              function updateBoard() {
  
  
                  if ($('#mText4').html() != mText4) {
                      animating = true;
                      $('#mText4').tween({
                          opacity: {
                            start: 100,
                            stop: 0,
                            time: 0,
                            duration: 0.5,
                            effect: 'easeIn'
                          },
                          onStop: function(){
                              $('#mText4').html(mText4);
                          }
                      });
  
                      $('#mText4').tween({
                          opacity: {
                            start: 0,
                            stop: 100,
                            time: 0.5,
                            duration: 0.5,
                            effect: 'easeOut'
                          },
                          onStop: function(){
                              animating = false;
                          }
                      });
                  }
  
                  $.play();
  
                  doUpdate = false;
              }
  
              function getValueFromTag (xmlDoc,tag) {
                  if (xmlDoc.getElementsByTagName(tag).length != 0 ) {
                      if (xmlDoc.getElementsByTagName(tag)[0].childNodes.length == 0) {
                              return '';
                          } else {
                              return xmlDoc.getElementsByTagName(tag)[0].childNodes[0].nodeValue;
                      }
                  } else {
                      return '';
                  }
              }
              &lt;/script&gt;
      &lt;div id="board"&gt;
          &lt;div id="mText4"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It works just fine, but after a few hours of having this (and two other html files) going, the software would crash. This caused me to look at the log files that it creates, and I was seeing the following a LOT of times:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'getElementsByTagName' of null @http://absolute/D:/obs%20stuff/browserfiles/Twitter1.html334
  </code></pre>
  
  <p>So I ran it in Firefox, and it was then throwing the following error (again, a LOT):</p>
  
  <pre><code>TypeError: xmlDoc is null
  </code></pre>
  
  <p>I know for sure that <code>streamcontrol.xml</code> is not null. I feel like those errors are pointing me in a good direction, but after about a collective 10+ hours over two days of trying different things I have seen on different threads, I am at a loss.</p>