in reply to Not able to replace element value using XML::Twig

Your example code actually works as expected. Are you sure you're looking at the replacement file? It's a bit easier to do the same thing with handlers:
my $twig = XML::Twig->new( twig_handlers => { stats => sub { $_->set_tag( 'stats_test' ) } } ); $twig->parse_file(...); $twig->flush;
as per the documentation.

Replies are listed 'Best First'.
Re^2: Not able to replace element value using XML::Twig
by newbie_ab (Novice) on Jan 25, 2010 at 13:48 UTC

    Thanks , I ran the code snippet you had posted but got the following error : Can't locate object method "parse_file" via package "XML::Twig" at ./xml_twig_test.thpl line 14. Isn't parse_file is a function which belongs to XML::LibXML package Thanks ab

      Try parsefile instead of parse_file.

      XML::Twig is an exceptionally well-documented CPAN module, and the parsefile method is described in its POD.

      There are many ways to search for information. Just typing "xml twig parse_file" into Google returns:

      Did you mean: xml twig parsefile Top 2 results shown