title: Can't retrieve nodes from XML doc in Javascript using getElementsByTagName
body: <p>I am trying to make an html page that essentially has two scroll boxes, one where I can view a tree like view of the node names in the document(which I have it set to create a button rather than plain text), then when you click on a node name in the tree view, it displays the value and attribute names of that node in the other box. I am loading the document using the standard load method suggested by w3schoools</p>
  
  <pre><code>function openSourceXML(){
  if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
  } else {// code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  ;
  xmlhttp.open("GET",
          "file:///C:/Users/conada/Downloads/FOPwc/dictionary.dic", false);
  xmlhttp.send();
  xmlDoc = xmlhttp.responseXML;
  };
  </code></pre>
  
  <p>I can construct the tree view part no problem using...</p>
  
  <pre><code>function start() {  
  x = xmlDoc.documentElement;
  document.getElementById("root").innerHTML = xmlDoc.documentElement.nodeName;
  document.write("&lt;br&gt;&lt;b&gt;&lt;font color=\"rgb(33,0,255)\" size=\"6\"&gt;"
          + x.nodeName + "&lt;/b&gt;&lt;/font&gt;");
  printChildren(x, 1);
  function printChildren(node, depth) {
      for ( var i = 0; i &lt; node.childNodes.length; ++i) {
          if (node.childNodes[i].nodeName != "#text") {
              document.write("&lt;br&gt;");
              if (depth == 1)
                  document.write("&lt;b&gt;&lt;font color=\"0000FF\" size=\"5\"&gt;");
              if (depth == 2)
                  document.write("&lt;font color=\"0088DD\" size=\"4\"&gt;");
              if (depth == 3)
                  document.write("&lt;font color=\"3318BB\" size=\"4\"&gt;");
              if (depth == 4)
                  document.write("&lt;font color=\"006688\" size=\"4\"&gt;");
              if (depth == 5)
                  document.write("&lt;font color=\"00DDFF\" size=\"4\"&gt;");
              for ( var j = 0; j &lt; depth; j++) {
                  document
                          .write("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp");
              }
              document.write("&lt;button type=\"button\" onClick=\"writeSome(this.value)\" value=\"" + node.childNodes[i].nodeName + "\"&gt;" + node.childNodes[i].nodeName +"&lt;/button&gt;");
  
              if (depth == 1)
                  document.write("&lt;/b&gt;&lt;/font&gt;");
              if (depth == 2)
                  document.write("&lt;/font&gt;");
              if (depth == 3)
                  document.write("&lt;/font&gt;");
              if (depth == 4)
                  document.write("&lt;/font&gt;");
  
          };
          printChildren(node.childNodes[i], depth + 1);
      };
  };
  };
  </code></pre>
  
  <p>When you click the button, it calls a function, passing it the selected node's name.The function then tries to use getElementsByTagName to retrieve the desired node, how ever this is where things come to a grinding halt. So far this function just simply displays the name of the node you should be getting, then after trying to get the node outputs the name (which should match logically). The function that is called by the button click is...</p>
  
  <pre><code>function writeSome(value){
  currNode=value; 
  //output passed string to ensure there is no problem there
  document.getElementById("rightPane").innerHTML = currNode + "&lt;br&gt;";
  //try to grab the node you want
  x = xmlDoc.getElementsByTagName(currNode);
  //display the name of the node to ensure the right node was found (should match name passed in)
  document.getElementById("rightPane").innerHTML += x.nodeName + "&lt;br&gt;";  
  };
  </code></pre>
  
  <p>The functions are all in one file which is external to my html. Why is it that getElementsByTagName seems to do nothing? How can I access a specific node given it's name if not this way? Any help would be great since I have exhausted my ideas for how to fix this.</p>
  
  <p>Also, side note, I have verified that some functions to access the XML file work, such as using xmlDoc.documentElement to retrieve the root node, the .childNodes after that to traverse through the file, but this is little use to me, I just want to grab the particular node I am looking for quick and cleanly.</p>