更新时间:2023-11-07 11:36:28
好的,关于我之前的评论,我现在找到了解决方案.
Okay, regarding my previous comment, I now found a solution.
似乎 toFile
绕过了 $skipXMLDeclaration
而 toString
没有.所以以下工作:
It seems toFile
bypasses $skipXMLDeclaration
whereas toString
doesn't. So the following works:
$XML::LibXML::skipXMLDeclaration = 1;
my $doc = XML::LibXML::Document->new;
# create your document
print $doc->toString;
(非常小的)缺点是您必须自己编写文件.
The (very small) downside is that you have to write the file yourself.