http://www.perlmonks.org?node_id=759715

Get a quick snapshot of the quantity and structure of elements in an XML file -- useful for getting acquainted with some new XML source, or for confirming expectations about XML data you created. (Yes, it is worthwhile to use XML::Parser in a one-liner...)
perl -MXML::Parser -le '$p=XML::Parser->new( Handlers=>{Start=>sub{$k.=".$_[1]";$h{$k}++}, End=>sub{$k=~s/.$_[1]$//;}}); $p->parsefile(shift); END{print "$h{$_}\t$_" for (sort keys %h)}' some_file.xml

(Line-breaks added for legibility; the first time I did this, it really was all on one line -- honest!)