我将 xml 转换为 xml 文件,我尝试将文本转换为源。我目前正在使用 xml::Twig,我需要输出而不需要对 xml 进行任何更改。
我试过了:
xml:
<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright © 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor & 2002.</imprint-text>
</book-meta>
</book>
脚本:
use strict;
use XML::Twig;
use XML::Xpath;
open(my $output , '>', "Output.xml") || die "can't open the Output $!\n";
my $xml_twig_content = XML::Twig->new(
twig_handlers => {
keep_atts_order => 1,
keep_encoding => 1,
},
pretty_print => 'indented',
);
$xml_twig_content->parsefile('sample.xml');
$xml_twig_content->print($output);
输出:
<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright © 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor & 2002.</imprint-text>
</book-meta>
</book>
我需要输出:
<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright © 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor & 2002.</imprint-text>
</book-meta>
</book>
我怎么能需要作为源而不做任何更改。