I have a problem. I am making some changes in XML code but sometimes it gets overlapped like:

```
<xref><mytag></xref></mytag>

```

I am thinking about a script that will parse XML file and fix that problem like:

```
<xref><mytag></mytag></xref><mytag></mytag>

```

Can anyone help my with that? Maybe some regular expression? Or some tool ready for use, python script etc. I got many files to fix and I will appreciate every advice!s