title: parse XML pairs with bash
body: <p>I've bumped myself into an interesting (at least for me) problem. Let's take an xml file:</p>
  
  <pre><code>&lt;a&gt;pair1a&lt;/a&gt;
  &lt;b&gt;pair1b&lt;/b&gt;
  &lt;c&gt;randomtext&lt;/c&gt;
  &lt;a&gt;pair2a&lt;/a&gt;
  &lt;b&gt;pair2b&lt;/b&gt;
  ...
  </code></pre>
  
  <p>the <code>&lt;b&gt;</code> tag goes always after <code>&lt;a&gt;</code> tag. What I want to get is the contents between <code>&lt;a&gt;</code> and <code>&lt;b&gt;</code> saved and associated together. How should I approach this problem in <em>bash</em> so that later I could easily access and manage data? I thought about associative arrays or putting everything in one array and separating a contents from b's with somekind of delimiter (althought this might be tricky). My approach was rather simple as in greping everything out into two arrays and then having them to use single index (btw, I've got used to perl regex and that's what grep is using). Can this be done simplier?</p>
  
  <pre><code>a_Array=$(curl --silent -L $xml | grep -oP '(?&lt;=&lt;a&gt;).*?(?=&lt;/a&gt;)')
  b_Array=$(curl --silent -L $xml | grep -oP '(?&lt;=&lt;b&gt;).*?(?=&lt;/b&gt;)')
  </code></pre>