title: Extract XML elements based on inner content
body: <p>I have a huge XML document (more than 12 GB) that I need to parse in the following way...</p>
  
  <p>Given a structure like this:</p>
  
  <pre><code>&lt;person name=Alice&gt;
     &lt;colour&gt;blue&lt;/colour&gt;
  &lt;/person&gt;
  
  &lt;person name=Bob&gt;
     &lt;colour&gt;green&lt;/colour&gt;
  &lt;/person&gt;
  
  &lt;person name=Charles&gt;
     &lt;colour&gt;blue&lt;/colour&gt;
  &lt;/person&gt;
  </code></pre>
  
  <p>I would like to extract in a separate file only those <code>person</code> elements that contains the subfield <code>&lt;colour&gt; blue &lt;/colour&gt;</code>.</p>
  
  <p>For example, given the previous XML code, the output of the program should be a separate file with the following content:</p>
  
  <pre><code>&lt;person name=Alice&gt;
     &lt;colour&gt;blue&lt;/colour&gt;
  &lt;/person&gt;
  
  &lt;person name=Charles&gt;
     &lt;colour&gt;blue&lt;/colour&gt;
  &lt;/person&gt;
  </code></pre>
  
  <p>I have tried to use <code>grep</code> and <code>sed</code>, as they are very useful tools for this purpose and also can manage huge files like mine, but I'm not quite sure about the regex I should use.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong>: as I have noted, I need a stream-based tool, as otherwise the program simply crashes! I've tried <code>xmlstarlet</code> but the program is auto-killed (I suppose due to memory use).</p>
  
  <p><strong>EDIT2</strong>: I also tried to split the file using <code>xml_split</code>, but the amount of subfiles generated is simply untreatable. So, any suggestion?</p>