title: Search Text and replace with lxml
body: <p>I need to search text in multi-line XML file where I have multiple tags. 
  My XML file looks like this </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&gt;
      &lt;system xmlns="http://www.abc.xyz"&gt;
        &lt;context&gt;
              &lt;name&gt;context_1&lt;/name&gt;
              &lt;host&gt;
                  &lt;name&gt;xyz&lt;/name&gt;
                  &lt;tag1&gt;
                      &lt;name&gt;pqr&lt;/name&gt;
                      &lt;role&gt;s1&lt;/role&gt;
                      &lt;tag2&gt;test&lt;/tag2&gt;
                  &lt;/tag1&gt;
                  &lt;tag2&gt;
                      &lt;name&gt;pqr&lt;/name&gt;
                      &lt;role&gt;s1&lt;/role&gt;
                      &lt;tag2&gt;test&lt;/tag2&gt;
                  &lt;/tag2&gt;              
              &lt;/host&gt;
        &lt;/context&gt;
      &lt;/system&gt;
  &lt;/nc:data&gt;
  </code></pre>
  
  <p>I want to search appearances of text <code>"test"</code> in the XML file and list their parent tag in the output. Unfortunately I am unable to do so.</p>
  
  <p>The Python code that I have written is : </p>
  
  <pre><code>import os
  import xml 
  import sys 
  from xml.dom import minidom
  import xml.etree.ElementTree as ET
  
  def xml_parsing():
      ''' 
      with open('file.xml', 'rt') as f:
          tree = ET.parse(f)
          for node in tree.findall('.//context'):
              print node, node.tag, node.attrib
              url = node.attrib.get('tag1')
              print url 
  
  xml_parsing()
  </code></pre>
  
  <p>I am getting blank result as output and unable to do anything beyond it. I have tried both <code>ElementTree</code> and <code>lxml</code>. I believe it has something to do with the search pattern that I am trying to find using <code>findall</code>.</p>
  
  <p>Please advise with your expert comments what should be tried now. </p>
  
  <p>I tried the SAX way as well and code is like this:</p>
  
  <pre><code>xmldoc = minidom.parse('file.xml')
  reflist = xmldoc.getElementsByTagName('tag1')
  print reflist[0].toxml()
  </code></pre>
  
  <p>But this returns me the complete line other than just the value between tags. </p>