title: Extract specific XML pattern from log file using 'awk'
body: <p>I would like to extract from a log file that contains mostly Java log data (debug/errors/info) the following XML:</p>
  
  <pre><code>&lt;envelope&gt;
      &lt;header&gt;
          ...
      &lt;/header&gt;
      &lt;body&gt;
          &lt;Provision&gt;
              &lt;ORDER id="XYZ_123_456" action="test"&gt;
                  ....
              &lt;/ORDER&gt;
          &lt;/Provision&gt;
      &lt;/body&gt;
  &lt;/envelope&gt;
  </code></pre>
  
  <p>I only need the one which has the "Provision" tag, and which contains the ORDER id XYZ_123_456</p>
  
  <p>I've tried using the following, but it also returns XMLs without the Provision tag. (I'm near clueless in awk, this is a code I've modified for this particular need)</p>
  
  <pre><code>awk '/&lt;envelope&gt;/ {line=$0; p=0 &amp;&amp; x=0; next}
       line   {line=line ORS $0}
      /ORDER/ &amp;&amp; $2~/XYZ_123_456/ {p=1}
      $0~/&lt;Provision&gt;/ {x=1}
     /&lt;\/envelope&gt;/ &amp;&amp; p &amp;&amp; x {print line;}' dump.file
  </code></pre>
  
  <p>Thanks!</p>