Rearrange XML code