test.xml:use strict; use warnings; use autodie; use XML::Twig; use File::Copy; use Encode; use File::Find::Rule; use XML::Twig; binmode STDOUT, ":utf8"; my $srcDCR='test.xml'; my $logend = $srcDCR; my $logfile = $logend . "log"; open LOG, ">$logfile"; my $tmpdcr = $srcDCR.".tmp"; copy($srcDCR,$tmpdcr); open (FILE,'>:encoding(UTF-8)',"$tmpdcr") or die "Failed to open $ +tmpdcr"; my $twig = XML::Twig->new (keep_encoding => 0); $twig->parsefile($srcDCR); my $root = $twig->root; my $littype_parent = $root->first_child('Metadata'); my $littype_value = $littype_parent->first_child_trimmed_text('Descrip +tion'); print LOG $littype_value; $littype_value = 'C1000 マネージ '; print LOG $littype_value; my $littype_child = $littype_parent->first_child('Description'); $littype_child->set_content($littype_value); print LOG 'final value'; print LOG $littype_parent->first_child_trimmed_text('Description'); $twig->print(\*FILE); close(FILE);
n the xml the value of description is getting set to C1000 マネージ instead of C1000 マネージ I am new to perl.<Metadata> <Description>C1000 マネージャー +2477;フトウェア</Description> </Metadata>
In reply to set_content of XML::twig by test1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |