我在做 xml 转换,在这里我将根标签定义为书,但是如何在这里定义未知的根标签,我需要通用语法,
use twig;
my $story_file = XML::Twig->new(
twig_handlers =>{
'book' => \&book,
keep_atts_order => 1,
},
pretty_print => 'indented',
);
$story_file->parsefile('unknown.xml');
$story_file->print($out);
我试过了,
use twig;
my $story_file = XML::Twig->new(
twig_handlers =>{
root => \&book,
keep_atts_order => 1,
},
pretty_print => 'indented',
);
$story_file->parsefile('unknown.xml');
$story_file->print($out);
它没有用,如果有任何用于根标签的 comman syntex,请举个例子