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.

```
<ds>
 <uint32 name='a'/>
 <uint32 name='b'/>
 <string name='c'/>
 <int16 name='d'/>
 <uint32 name='e'/>
</ds>

```

Parsing this XML file normally allows me to generate the following hash

```
   $VAR1 = {
      'uint32' => {
                  'e' => {},
                  'a' => {},
                  'b' => {}
                },
      'int16' => {
                 'name' => 'd'
               },
      'string' => {
                  'name' => 'c'
                }
    };

```

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 data structure.

I would like to find out offsets of each of these elements.

I tried searching for a XML parser which allows me to parse an XML file sequentially, something like a 'getnexttag()' kind of a functionality, but could not find any.

What is the best way to do this programmatically? If not python, then which other language is best suited to do this work?