如何使用xml :: Twig更改标签?

时间:2015-08-14 07:01:02

标签: xml xml-twig

我是xml :: Twig的新手,我需要在我的xml中更改一对一的链接标记,我没有一个概念,...我面临很多问题......

我的输入:

<?xml version="1.0"?>
<root>
<p><a href="#fn001" id="fn_001">1</a> this a footnote reference</p>
<p>This a simple text</p>
<p>This a simple text</p>
<p>This a simple text</p>
<p><a href="#fn_001" id="fn001">1</a> this a footnote reference</p>
</root>

需要:

<?xml version="1.0"?>
<root>
<p><a href="#fn001" id="fn_001">1</a> this a footnote reference</p>
<p>This a simple text</p>
<p>This a simple text</p>
<p>This a simple text</p>
<p><anchor href="#fn_001" id="fn001">1</anchor> this a footnote reference</p>
</root>

我需要使用第一个<a>标记href链接,我需要搜索它调用的地方,该标记仅在文档中更改为锚点。当我到达第二个时,不需要找到它,因为它会像锚一样改变....,这个概念使用许多一对一<a>标签,第一个只需要不需要改变.....谢谢

use strict;
use XML::Twig;
my $xml = XML::Twig->new(twig_handlers => {
},
pretty_print => 'indented',
keep_encoding => 1,
);
$xml->parsefile("sample.xml");

我使用此代码,但我在此代码中没有做任何事情......因为我没有解决方案......是否可能......?

0 个答案:

没有答案