I can get the example output. And for the structure like "<tag> text1 <tag> text2 <tag> text3 </tag> </tag></tag>", the output of my code is like "<tag> text1 <tag> text2 <tag> text3 </tag> </tag></tag> <tag> text2 <tag> text3 </tag> </tag> <tag> text3 </tag>" It's hard for myself to figure out the problems. Hope someone could help me out. Appreciate it!