String maniputlation? Hmmm. While I value your article and would in no way fault your approach, there are much better alternatives - that are not too far off from where you are.
Explorer this:
for xml path ('application'), ROOT('applications')
I think you will find that it is a better approach.
-M