我是新手xml::Twig
。如何vmerge
通过特定计数从标签计数中添加属性和值vmerge
?我该如何开始呢?在这个过程中使用了什么逻辑?
到目前为止我的脚本:
use XML::Twig;
my $XMLHandler = XML::Twig->new(TwigHandlers => {
},
pretty_print => 'indented',
);
$XMLHandler->parsefile("sample.xml");
$XMLHandler->print;
输入 XML:
<xml>
<table>
<tr>
<column><vmerge value="start"/></column>
<column></column>
<column></column>
<column><vmerge value="start"/></column>
</tr>
<tr>
<column><vmerge/></column>
<column></column>
<column></column>
<column><vmerge/></column>
</tr>
<tr>
<column><vmerge value="start"/></column>
<column></column>
<column></column>
<column><vmerge/></column>
</tr>
<tr>
<column><vmerge/></column>
<column></column>
<column></column>
<column><vmerge/></column>
</tr>
</table>
</xml>
我需要输出如下:
<xml>
<table>
<tr>
<column rowspan="2"></column>
<column></column>
<column></column>
<column rowspan="4"></column>
</tr>
<tr>
<column></column>
<column></column>
<column></column>
<column></column>
</tr>
<tr>
<column rowspan="2"></column>
<column></column>
<column></column>
<column></column>
</tr>
<tr>
<column></column>
<column></column>
<column></column>
<column></column>
</tr>
</table>
</xml>