in reply to Using XML Twig to summarize a large file

I really can't make sense of your code, but if you want to output the list of used elements and how many times they were used, then you can install XML::PYX and use the following one-liner:

pyx 'bigXMLfile.xml | perl -n -e '$nb{$1}++ if( m/\A\((.*)\n/); \ END { map { print "$_ used $nb{$_} time(s) +\n";} sort keys %nb;}'

There are of course ways to do this using XML::Twig, but as incredible as it might seem, every now and then it is not the easiest module to use. ;--)