title: Getting nodes/child nodes from html
body: <p>The first thing I do is I echo some html code:</p>
  
  <pre><code>echo "&lt;div&gt;
          &lt;file&gt;somefile&lt;/file&gt;
          &lt;file&gt;another file&lt;/file&gt;
        &lt;/div&gt;";
  </code></pre>
  
  <p>Then I through JavaScript find all instances of file:</p>
  
  <pre><code>var file = document.getElementsByTagName("file");
  </code></pre>
  
  <p>Then I am able to get values from each file by:</p>
  
  <pre><code>file[index].childNodes[0].nodeValue
  </code></pre>
  
  <p>Now I want to add another level to the <code>&lt;file&gt;</code> like this:</p>
  
  <pre><code>echo "&lt;div&gt;
          &lt;file&gt;
            &lt;em1&gt;element1&lt;/em1&gt;
            &lt;em2&gt;element2&lt;/em2&gt;
          &lt;/file&gt;
        &lt;/div&gt;";
  </code></pre>
  
  <p>How can I get those em values? I want to do something like:</p>
  
  <pre><code>file[index].getValueFromEm1...
  </code></pre>