title: Javascript: Getting values out of an XML file with weird formatting (Recursion?)
body: <p>I'm trying to iterate through an XML file that has weird formatting (I used pdftohtml to make the xml file and the output I get is weird but it's more usable than outputting to HTML)</p>
  
  <p>Here's an example:</p>
  
  <pre><code>&lt;text height="11" font="3"&gt;Lastname1, Firstname1&lt;/text&gt;
  &lt;text height="11" font="3"&gt;111111-1&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="11" font="3"&gt;Lastname2, Firstname2&lt;/text&gt;
  &lt;text height="11" font="3"&gt;222222-2&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="11" font="3"&gt;Lastname3, Firstname3&lt;/text&gt;
  &lt;text height="11" font="3"&gt;name3long&lt;/text&gt;
  &lt;text height="11" font="3"&gt;333333-3&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="6" font="2"&gt;random text&lt;/text&gt;
  &lt;text height="11" font="3"&gt;Lastname4, Firstname4&lt;/text&gt;
  &lt;text height="11" font="3"&gt;444444-4&lt;/text&gt;
  &lt;text height="11" font="3"&gt;Lastname5, Firstname5&lt;/text&gt;
  &lt;text height="11" font="3"&gt;555555-5&lt;/text&gt;
  &lt;text height="11" font="3"&gt;Lastname6, Firstname6&lt;/text&gt;
  &lt;text height="11" font="3"&gt;name6long&lt;/text&gt;
  &lt;text height="11" font="3"&gt;666666-3&lt;/text&gt;
  </code></pre>
  
  <p>To break it down.  The Name block starts with the name with attributes of height: 11, font: 3 and ends with the ID that has the same attributes but it is always length: 8.  </p>
  
  <p>I thought recursion would solve my problem but it doesn't give me the output I want as I'm trying to get the line numbers of where the name block starts and where it ends.</p>
  
  <p>Here's a sample of the code I'm using</p>
  
  <pre><code>var txt = xml.getElementsByTagName('text');
  
      function block(b){
          var line = txt[b];
          if(line.innerHTML.length == 8){
              return b;
          }
          else{
              block(b+1);
          }
      }
  
  
      function getNameBlock(){
  
          // Notes: Name and Employee ID has attributes of height: 11 and font: 3
          // Employee ID has always length: 8;
          //
          // Start value should be assigned when we hit the attributes of height: 11, left: 62, font: 3
          // End value should be assigned when we hit the attributes above as well as length: 8
          // Console output will be start and end values
  
          for(var i=0;i&lt;txt.length;i++){
              var line = txt[i];
              var start;
              var end;
              if(line.getAttribute('height') == '11' &amp;&amp;  line.getAttribute('font') == 3){
                  start = i;
                  end = block(start)
  
                  console.log("Start: "+start+" End: "+end);
  
              }
  
          }
      }
  </code></pre>
  
  <p>My output isn't working the way I want it to because it gives me:</p>
  
  <pre><code>Start: 0 End: undefined
  Start: 1 End: 1
  Start: 4 End: undefined
  Start: 5 End: 5
  etc....
  </code></pre>
  
  <p>Am I just trying to complicate things with recursion?</p>