title: How can I extract attributes from repeated tags in XML using Perl?
body: <p>I am trying to parse a set of XML files. The XML file may have single flag tag or multiple flag tags:</p>
  
  <pre><code>&lt;job&gt;   &lt;flag exit="0"&gt;aaa&lt;/flag&gt; &lt;/job&gt;
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>&lt;job&gt;
    &lt;flag exit="0"&gt;aaa&lt;/flag&gt;
    &lt;flag exit="1"&gt;bbb&lt;/flag&gt;
    &lt;flag exit="2"&gt;ccc&lt;/flag&gt;
  &lt;/job&gt;
  </code></pre>
  
  <p>But determining this "flag" count has to be determined on the fly. What's the best way to determine the flag count and print the values in it?</p>