use strict; use warnings; use 5.010; use XML::Simple; use XML::MyXML; use XML::Twig; my $twig= new XML::Twig( twig_handlers => { testcase => \&testcase }); # create the twig $twig->parsefile( 'D:\\ABC\\Perl Projects\\DCA.xml'); #$twig->print; my $root= $twig->root; #$root->set_tag( 'html'); $twig->print; my @testcase = $root->children('testcase'); # foreach my $testcase (@testcase) # { $testcase->set_tag('p'); } # turn them into p $twig->print; sub testcase{ my ($twig, $testcase) = @_; print $testcase->field('command6'); print $testcase->att('type'); print "\n"; }