title: How to extract block of XML from a log file on Linux
body: <p>I have a log file that looks like the following:</p>
  
  <pre><code>2010-05-12 12:23:45 Some sort of log entry
  2010-05-12 01:45:12 Request XML: &lt;RootTag&gt;
  &lt;Element&gt;Value&lt;/Element&gt;
  &lt;Element&gt;Another Value&lt;/Element&gt;
  &lt;/RootTag&gt;
  2010-05-12 01:45:32 Response XML: &lt;ResponseRoot&gt;
  &lt;Element&gt;Value&lt;/Element&gt;
  &lt;/ResponseRoot&gt;
  2010-05-12 01:45:49 Another log entry
  </code></pre>
  
  <p>What I want to do is extract the Request and Response XML (and ultimately dump them into their own single files). I had a similar parser that used egrep but the XML was all on one line, not multiple ones like above.</p>
  
  <p>The log files are also somewhat large, hitting 500-600 megs a log. Smaller logs I would read in via a PHP script and use regex matching, but the amount of memory required for such a large file would more than likely kill the script.</p>
  
  <p>Is there an easy way using the built-in tools on a Linux box (CentOS in this case) to extract multiple lines or am I going to have to bite the bullet and use Perl or PHP to read in the entire file to extract it?</p>