use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new( twig_handlers=>{ content=> \&content_handler, }, ); $twig->parse(\*DATA); $twig->flush; sub content_handler { my ($twig, $content)= @_; if($content->{'att'}->{'type'} eq "text") { my $selfatt=$content->att_xml_string('Self'); my $expr='//box[@textflowid="'.$selfatt.'"][@type="text"]'; my @tagnames = $twig->get_xpath($expr); for my $temp (@tagnames) { my $fcnvar=$temp->att_xml_string('frameColorID'); # print "#$fcnvar#"; # if (!($fcnvar eq "")){ # my $expr='//color[@self="ua5"]'; # print "$expr"; # my @colorvalarr = $twig->get_xpath($expr); # print @colorvalarr; # print $colorvalarr[0]; # $fcnvar=$colorvalarr[0]->att_xml_string('pnam'); # } $content->set_tag('updated_tag'); $content->del_atts; $content->set_atts } } } __DATA__
h3