1
我需要在子元素中插入一個子元素。我有兩個孩子,第一個孩子剪切並粘貼到第二個孩子插入爲第一個孩子。如何插入子xml樹枝
XML:
<fn id="fn1_1">
<label>1</label>
<p>The distinguished as &#x2018;bisexuation.&#x2019;</p>
</fn>
我試圖
sub fngroup{
my ($xml_twig_content, $fn_group) = @_;
@text = $fn_group->children;
my $cut;
foreach my $fn (@text){
$cut = $fn->cut if ($fn->name =~ /label/);
if ($fn =~ /p/){
$fn->paste('first_child', $cut);
}
}
}
我不能處理它。我如何剪切標籤並將標籤粘貼粘貼到p標籤上作爲first_child。
我需要:
<fn id="fn1_1">
<p><label>1</label> The distinguished as &#x2018;bisexuation.&#x2019;</p>
</fn>
非常感謝你,它的工作太棒了.. – user1811486