title: Get inner elements from XML file with JavaScript
body: <p>I have an XML file with table tennis rules I want to parse to HTML with JavaScript. Heres the XML:</p>
  
  <pre><code>&lt;rulesection&gt;
          &lt;sectiontitle&gt;A let&lt;/sectiontitle&gt;
          &lt;rule&gt;
              &lt;point&gt;2.09.01&lt;/point&gt;
              &lt;description&gt;
                  The rally shall be a let
              &lt;/description&gt;
          &lt;subrule&gt;
              &lt;point&gt;2.09.01.01&lt;/point&gt;
              &lt;description&gt;
                  if in service the ball, in passing over or around the net assembly, touches it, provided the service is otherwise correct or the ball is obstructed by the receiver or his or her partner;
              &lt;/description&gt;
          &lt;/subrule&gt;
  &lt;/rule&gt;
  &lt;/rulesection&gt;
  </code></pre>
  
  <p>I have some JavaScript code so I can get the sectiontitle, point and description. Unfortunately I can´t seem to get the subrules and Google wont help me with this. With the code I have now I only get the first rule of every rulesection.</p>
  
  <pre><code>    &lt;script&gt;
  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", "fuckrules.xml", false);
  xmlhttp.send();
  xmlDoc = xmlhttp.responseXML;
  
  
  var x = xmlDoc.getElementsByTagName("rulesection");
  for (i = 0; i &lt; x.length; i++) {
      document.write("&lt;br&gt;");
      document.write(x[i].getElementsByTagName("sectiontitle")[0].childNodes[0].nodeValue);
      document.write("&lt;br&gt;");
      document.write(x[i].getElementsByTagName("point")[0].childNodes[0].nodeValue);
      document.write("&lt;br&gt;");
      document.write(x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I have tried to use multiple for-loops but I still cant get the points and descriptions of the subrules inside a rule. If anyone could give me some pointers that would be really helpful :)</p>