我有一个看起来像的 xml 文件
<?xml version="1.0"?>
<product = "AAA">
<shell name = "110">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
</product>
<product = "AAA">
<shell name = "310">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
</product>
<product = "BBB">
<shell name = "10">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
</product>
<product = "BBB">
<shell name = "10010">
<style = "0300" size ="3"/>
<style = "2030" size ="3"/>
<style = "8003" size ="1"/>
<style = "09003" size ="3"/>
</shell name>
</product>
<product = "BBB">
<shell name = "110">
<style = "0300" size ="3"/>
<style = "2030" size ="3"/>
<style = "8003" size ="1"/>
<style = "09003" size ="3"/>
</shell name>
</product>
我想编写一个脚本,该脚本应该包含同一产品的外壳,以便我有类似的输出
<?xml version="1.0"?>
<product = AAA>
<shell name = "110">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
<shell name = "310">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
</product>
<product = BBB>
<shell name = "10">
<style = "000" size ="3"/>
<style = "200" size ="3"/>
<style = "800" size ="1"/>
<style = "0900" size ="3"/>
</shell name>
<shell name = "10010">
<style = "0300" size ="3"/>
<style = "2030" size ="3"/>
<style = "8003" size ="1"/>
<style = "09003" size ="3"/>
</shell name>
<shell name = "110">
<style = "0300" size ="3"/>
<style = "2030" size ="3"/>
<style = "8003" size ="1"/>
<style = "09003" size ="3"/>
</shell name>
</product>
关于我如何进行的任何想法???我正在考虑搜索一个字符串 </product>
<product = "AAA">
但我怎样才能达到第二次出现。我知道如何读取文件并计算特定字符串的出现次数,但是任何人都可以帮助我如何达到特定字符串的第二次出现?