title: Beautifulsoup: Looping over elements to get text
body: <p>I am learning BeautifulSoup and have a webpage that has a body something like this:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;div&gt;
   &lt;table&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;div&gt;
       &lt;a name='abc'&gt;....&lt;/a&gt;
     &lt;/div&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;a name='pqr'&gt;...&lt;/a&gt; 
  &lt;div&gt;text1&lt;/div&gt;
  &lt;div&gt;text2&lt;/div&gt;
  &lt;div&gt;text3&lt;/div&gt;
   &lt;a name='mno'&gt;...&lt;/a&gt; 
  
  &lt;div&gt;
   &lt;table&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;div&gt;
       &lt;a name='xyz'&gt;....&lt;/a&gt;
     &lt;/div&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Expected result: </p>
  
  <pre><code>&lt;a name='pqr'&gt;...&lt;/a&gt; 
  &lt;div&gt;text1&lt;/div&gt;
  &lt;div&gt;text2&lt;/div&gt;
  &lt;div&gt;text3&lt;/div&gt; 
  &lt;a name='mno'&gt;...&lt;/a&gt;
  </code></pre>
  
  <p>I mean, getting all content until  'a name='xyz'' tag is reached </p>