【发布时间】:2020-06-24 07:11:04
【问题描述】:
我无法使用 xml Twig 模块更新 xml 标签中的内容。
这是我的 xml 文件:-
<?xml version="1.0"?>
<test customerProprietary="false">
<classes>
<class name="new" />
</classes>
<chars>
<log>false</log>
</chars>
</test>
代码sn-p:-
my $twig = XML::Twig->new(
pretty_print => 'indented',
twig_handlers => {
log => sub {
if ($_->text eq 'true'){
exit;
}
else{
print $_->text;
subp4open($xmlfile);
$_->set_text( 'true' );
exit;
}
}
);
$twig->parsefile($script_path);
$twig->print_to_file($script_path);
我必须将<log>false</log> 更新为<log>true</log>。我在这里错过了什么吗?
【问题讨论】: