Thanks for your replies. But the above message is jst a sample and the exact message we get is pretty huge(its a trading sysem message)... I do have XML Parser installed.. I was trying to format a sample message using start and a default handler. I do get data in a variable and can change it, but how do I get the changed XML message in a new file. My question might be confusing or silly, but thats where I am currently stuck . I just wrote a dummy script-
#!/usr/bin/perl use XML::Parser; use Data::Dumper ; open(XML, "a.txt") || die("Could not open file XML_FILE !"); ### handler my $Data = <XML>; close(XML); &ReplaceXMLValue($Data,'MOSP_Trader_Code','1111111111111'); sub ReplaceXMLValue { my $Data = shift @_; my $tagName = shift @_; my $NewValue = shift @_; my $parser = new XML::Parser ( Handlers => { # Creates our parser object Start => \&hdl_start, Default => \&hdl_default, }); $parser->parse($Data); print " \n\n\n Formatted data is - $Data \n\n\n"; } # The Handlers sub hdl_start{ my ($p, $elt, %atts) = @_; return unless $elt eq 'MOSP_Trader_Code'; # We're only interrested in what's said $flag=1; } sub hdl_default { my ($p, $data) = @_; if ($flag == 1) { print "Inside default handler \n"; if ($data eq 'CHL') { print "chaging data value form CHL to POST\n"; $data ='POST'; print "$data\n"; $flag =0; } } } # End of default_handler -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/