use strict; use warnings; use XML::Twig; my $xfile = < Content Content EOF my $t= new XML::Twig(); $t->parse($xfile); my $sub = $t->root(); for my $elm ($sub->first_child('INNERSUB')->children()) { print $elm->name(), "\n"; print $elm->att('Type'), "\n"; print $elm->text(), "\n\n"; } __END__ Element1 Type1 Content Element2 Type2 Content