title: perl: how to parse an xml file sequentially
body: <p>I have an XML file which describes the data-structure that I can exchange on a UDP channel.
  For example:
  Here is my input XML file describing my data-structure.</p>
  
  <pre><code>&lt;ds&gt;
   &lt;uint32 name='a'/&gt;
   &lt;uint32 name='b'/&gt;
   &lt;string name='c'/&gt;
   &lt;int16 name='d'/&gt;
   &lt;uint32 name='e'/&gt;
  &lt;/ds&gt;
  </code></pre>
  
  <p>Parsing this XML file using perl's XML:Simple, allows me to generate the following hash</p>
  
  <pre><code>$VAR1 = {
            'uint32' =&gt; {
                        'e' =&gt; {},
                        'a' =&gt; {},
                        'b' =&gt; {}
                      },
            'int16' =&gt; {
                       'name' =&gt; 'd'
                     },
            'string' =&gt; {
                        'name' =&gt; 'c'
                      }
          };
  </code></pre>
  
  <p>As you can see, after parsing I have no way to figure out what will be the relative position of field 'e' relative to the start of the datastructure.</p>
  
  <p>I would like to find out offsets of each of these elements.</p>
  
  <p>I tried searching for a perl XML parser which allows me to parse an XML file sequentially, something like a 'getnexttag()' kind of a functionality, but could not find any.</p>
  
  <p>What is the best way to do this programmatically? If not perl, then which other language is best suited to do this work?</p>