本文介绍了XML标记最后关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是Perl的新手,我想在每章结尾处关闭book-part标签,并且我有n个章节,例如,book-part应该在下一章开始之前关闭,
我尝试了以下代码,但无法显示任何更改

Hi,
I''m newbie to Perl,i want to close the book-part tag at the end of each chapter and i have n chapters,i.e)book-part should be close before the next chapter begin,
i tried the below code but it couldn''t show any changes

if($str =~ /<book-part book-part-type="chapter" id="chapter\d+">((?:(?!<\/?book-part book-part-type="chapter" id="chapter\d+">).)*)(?=<book-part book-part-type="chapter" id="chapter\d+">)/sgi)
    {
    $str .="<book-part>";
    }


每章都以下面的标签开头


each chapter begin with this below tag

<book-part book-part-type="chapter" book-part-number="\d+" id="chapter\d+">


我想生成这样的输出


and i want to generate a output like this

</book-part>
<book-part book-part-type="chapter" book-part-number="2" id="chapter2"


</book-part>

是第一章的结束标记,

<book-part book-part-type>

是第二章的开始标记.
请任何人帮助我解决我的问题.......

is a second chapter''s opening.
plz any one help me to solve my problem.......

推荐答案



每章都以下面的标签开头


each chapter begin with this below tag

<book-part book-part-type="chapter" book-part-number="\d+" id="chapter\d+">


我想生成这样的输出


and i want to generate a output like this

</book-part>
<book-part book-part-type="chapter" book-part-number="2" id="chapter2"


</book-part>

是第一章的结束标记,

<book-part book-part-type>

是第二章的开始标记.
请任何人帮助我解决我的问题.......

is a second chapter''s opening.
plz any one help me to solve my problem.......


my


这篇关于XML标记最后关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 17:16