MyCode: use warnings; use 5.010; use XML::Simple; #using XML::Parser use XML::Parser; my $parser = new XML::Parser; $parser->setHandlers(Start => \&startElement, End => \&endElement); $parser->parsefile('D:\\ABC\\Perl Projects\\DCA.xml'); sub startElement { my( $parseinst, $element, %attrs ) = @_; SWITCH: { if ($element eq "testcase") { $count++; $tag = "testcase"; print "Testcase $count:\n"; for my $attr (keys %attrs) { print "$attr: $attrs{$attr}\n"; } last SWITCH; } if ($element eq "step") { print "Step: "; $tag = "step"; for my $attr (keys %attrs) { print "$attr: $attrs{$attr}\n"; } last SWITCH; } } } sub endElement { my( $parseinst, $element ) = @_; if ($element eq "testcase") { print "\n\n"; } elsif ($element eq "title") { print "\n"; } } Output of my script Testcase 1: type: Interactive Step: param2: dirpath param1: executablepath command: Launchsimulator Step: command: Homescreen Step: param1: 100 command: Channelchange Step: param4: 580 param2: 96 param3: 726 param1: 3 command: CaptureRectanlge Step: param2: D:\\img2.jpg param1: D:\\img1.jpg command: CompareImage Testcase 2: type: Netfront Step: param2: dirpath param1: executablepath command: Launchsimulator Step: command: Homescreen Step: param1: 100 command: Channelchange Step: param4: 580 param2: 96 param3: 726 param1: 3 command: CaptureRectanlge Step: image1: D:\\img1.jpg image2: D:\\img2.jpg command: CompareImage Testcase 3: type: HTML