title: Using PHP regex to parse XML
body: <p>How can I use a regular expression to parse XML?</p>
  
  <p>Let's suppose we have the following:</p>
  
  <pre><code>$string = '&lt;z&gt;1a&lt;z&gt;2b&lt;/z&gt;3c&lt;z&gt;4d&lt;/z&gt;5e&lt;/z&gt;';
  preg_match_all('/&lt;z&gt;(.+)&lt;\/z&gt;/', $string, $result_a);
  preg_match_all('/&lt;z&gt;(.+)&lt;\/z&gt;/U', $string, $result_b);
  preg_match_all($regex, $string, $result_x);
  </code></pre>
  
  <p>If I run that, then $result_a will have the string (among the items of the array):</p>
  
  <pre><code>'1a&lt;z&gt;2b&lt;/z&gt;3c&lt;z&gt;4d&lt;/z&gt;5e'
  </code></pre>
  
  <p>In addition, variable $result_b will have the strings (among the items of the array):</p>
  
  <pre><code>'1a&lt;z&gt;2b'
  '4d'
  </code></pre>
  
  <p>Now, I want <code>$result_x</code> to have '2b' and '4d' separately, among the items of the array.</p>
  
  <p>What should <code>$regex</code> look like?</p>
  
  <p>Thanks in advance!!!</p>