title: Python XML Parsing regex
body: <p><strong>Object: Match strings in file to string in XML. Replace
  Match with comments</strong></p>
  
  <p><strong>cat File.txt</strong></p>
  
  <pre><code>RHO_BID_RT
  RHO_ASK_RT
  </code></pre>
  
  <p><strong>XML FILE CONTENTS</strong></p>
  
  <pre><code>&lt;field name="RHO_BID_RT" type="float" id="0x01D3" sequence="1"/&gt;
  &lt;field name="RHO_ASK_RT" type="float" id="0x01D4" sequence="1"/&gt;
  </code></pre>
  
  <p><strong>INTENDED RESULTS in XML CONTENTS</strong></p>
  
  <pre><code> &lt;!-- Removed RHO_BID_RT--&gt;
   &lt;!-- Removed RHO_ASK_RT--&gt;
  </code></pre>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>import re
  
  word_file = 'File.txt'
  xml_file  = '../file.xml'
  
  with open(word_file) as words:
      regex = r'&lt;[^&gt;]+ *field name="({})"[^&gt;]+&gt;'.format(
          '|'.join(word.rstrip() for word in words)
      )
  
  with open(xml_file) as xml:
      for line in xml:
          line = re.sub(regex, r'&lt;!!-- REMOVED \1 --&gt;', line.rstrip())
          print(line)
  </code></pre>