【发布时间】:2013-10-16 18:36:24
【问题描述】:
我正在使用 XML::LibXML,我想添加一个注释,使该注释位于标签之外。甚至可以将其放在标签之外吗?我试过 appendChild, insertBefore |之后,没区别……
<JJ>junk</JJ> <!--My comment Here!-->
# Code excerpt from within a foreach loop:
my $elem = $dom->createElement("JJ");
my $txt_node = $dom->createTextNode("junk");
my $cmt = $dom->createComment("My comment Here!");
$elem->appendChild($txt_node);
$b->appendChild($elem);
$b->appendChild($frag);
$elem->appendChild($cmt);
# but it puts the comment between the tags ...
<JJ>junk<!--My comment Here!--></JJ>
【问题讨论】:
标签: perl libxml2 xml-libxml