我是 xml-twig 的新手,如何拆分父标签?
文件:
<xml>
<p class="indent">text text incluce <div>text</div> ateas</p>
<p class="text">text text incluce <div>text</div> ateas</p>
</xml>
我需要输出为:
<xml>
<p class="indent">text text incluce</p>
<div>text</div>
<p class="indent">ateas</p>
<p class="text">text text incluce</p>
<div>text</div>
<p class="text">ateas</p>
</xml>
如何拆分标签?
use strict;
use XML::Twig;
open(my $output , '>', "split.xml") || die "can't open the Output $!\n";
my $xml_twig_content = XML::Twig->new(
'p' => \&split, )
$xml_twig_content->parsefile("sample.xml");
$xml_twig_content->print($output);
sub split{
my ($xml_twig_content, $p) = @_;
}
如何拆分标签?...