title: Time-efficient algos to identify and replace garbled text with corrected one
body: <p>I have a file containing XML tags with potentially garbled text content. I have another file containing a plaintext correction of the tag content. I cannot reconstruct the XML from the plaintext. Are there efficient algos to match fragments of the corrected text to the potentially-garbled XML text content? The plaintext and XML contain mostly the same 'ideal' text, but not 100%. The order of the text in both files is most often the same, but not always.</p>
  <p>Example:<br />
  XML:<br />
  <code>&lt;p&gt;&lt;p&gt;Lorem ip[sum d o l o r sitamet.&lt;/p&gt;&lt;p&gt;An aside&lt;/p&gt;&lt;p&gt;C.   onsectetur adipiscing elit.&lt;/p&gt;&lt;p&gt;Lorem ipsum, I say again, dolor sit amet.&lt;/p&gt;</code></p>
  <p>Plaintext:<br />
  <code>Lorem ipsum dolor sit amet. Consectetur adipiscing elit. Lorem ipsum, I say again, dolor sit amet.</code></p>
  <p>Desired result:<br />
  <code>&lt;p&gt;&lt;p&gt;Lorem ipsum dolor sit amet.&lt;/p&gt;&lt;p&gt;An aside&lt;/p&gt;&lt;p&gt;Consectetur adipiscing elit.&lt;/p&gt;&lt;p&gt;Lorem ipsum, I say again, dolor sit amet.&lt;/p&gt;&lt;/p&gt;</code></p>
  <p>For now I use variations on identifying the beginning and end of a tag's content in the plaintext, and estimating whether that's reasonably close with Levenshtein distance or ad-hoc measures, but those are often of quadratic complexity. Is there anything more clever?</p>