title: Combine multiple tags with lxml
body: <p>I have an html file which looks like:</p>
  
  <pre><code>...
  &lt;p&gt;  
      &lt;strong&gt;This is &lt;/strong&gt;  
      &lt;strong&gt;a lin&lt;/strong&gt;  
      &lt;strong&gt;e which I want to &lt;/strong&gt;  
      &lt;strong&gt;join.&lt;/strong&gt;  
  &lt;/p&gt;
  &lt;p&gt;
      2.
      &lt;strong&gt;But do not &lt;/strong&gt;
      &lt;strong&gt;touch this&lt;/strong&gt;
      &lt;em&gt;Maybe some other tags as well.&lt;/em&gt;
      bla bla blah...
  &lt;/p&gt;
  ...
  </code></pre>
  
  <p>What I need is, if all the tags in a 'p' block are 'strong', then combine them into one line, i.e.</p>
  
  <pre><code>&lt;p&gt;
      &lt;strong&gt;This is a line which I want to join.&lt;/strong&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>Without touching the other block since it contains something else.</p>
  
  <p>Any suggestions? I am using lxml.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>So far I tried:</p>
  
  <pre><code>for p in self.tree.xpath('//body/p'):
          if p.tail is None: #no text before first element
              children = p.getchildren()
              for child in children:
                  if len(children)==1 or child.tag!='strong' or child.tail is not None:
                      break
              else:
                  etree.strip_tags(p,'strong')
  </code></pre>
  
  <p>With these code I was able to strip off the strong tag in the part desired, giving:</p>
  
  <pre><code>&lt;p&gt;
        This is a line which I want to join.  
  &lt;/p&gt;  
  </code></pre>
  
  <p>So now I just need a way to put the tag back in...</p>