title: JavaScript will alert nodeValue, but when trying to display the text, it's null or causes errors
body: <p>I have been having tremendous trouble getting this to work. There is no reason (to my knowledge) that this shouldn't work.</p>
  
  <pre><code>var xpath = '/course/module[@id=\''+modId+'\']/child::*';
  var getData = sxe(xmldoc, xpath);
  var result = getData.iterateNext();
  </code></pre>
  
  <p>The function returns the xpath. Just looks cleaner. This works 100%.</p>
  
  <pre><code>while (results)
  {
      var text = result.getElementsByTagName('title')[0].nodeValue;
      document.write(text); // returns null
  }
  </code></pre>
  
  <p>For the example, I use document.write, it returns null, but in my actual script, it usually says <code>childNodes</code> or whatever method I'm trying to access the data (I thought this would help) it never returns it. It causes an error and breaks it. When I use <code>alert()</code>, I get the exact text I want, everything works perfectly!</p>
  
  <p>What is happening?!</p>