use XML::Rules; my $parser = XML::Rules->new( rules => [ Item => sub { $_[1]->{Name} => $_[1]->{_content}}, # take only the name and content from the # and make it available using the Name as the key Id => 'content', DocSum => sub { print "Id: $_[1]->{Id}\nName: $_[1]->{Name}\nFoo: $_[1]->{Foo1}, $_[1]->{Foo2}\n\n"; return; # we are done with the , no need to keep the data }, ] ); $parser->parse($the_file);