title: Bash: parsing XML block into an array
body: <p>I have an xml-like textfile which I would like to parse into an array. The input file looks like this</p>
  
  <pre><code>&lt;AA&gt;
    &lt;BB&gt;content 1&lt;/BB&gt;
  &lt;/AA&gt;
  &lt;AA&gt;
    &lt;BB&gt;content 2&lt;/BB&gt;
  &lt;/AA&gt;
  </code></pre>
  
  <p>I want the output to be like (meaning one whole AA-block per array element):</p>
  
  <pre><code>ARRAY[0]=&lt;AA&gt;&lt;BB&gt;content 1&lt;/BB&gt;&lt;/AA&gt;
  ARRAY[1]=&lt;AA&gt;&lt;BB&gt;content 2&lt;/BB&gt;&lt;/AA&gt;
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>ARRAY=(`cat input.txt | grep -A 3 \&lt;AA\&gt;`)
  </code></pre>
  
  <p>but this only returns me one line per array element. Does anyone have an idea?</p>