You've saved me from working on something similar today - thanks. We received a bunch of XML that has no indentation or whitespace that I'll need to 'clean up'. I'll be taking your code out for a spin when I get to work today.
This is as good a time as any to mention this but this is only something you want to do if whitespace nodes between tags isn't important to you. In my case I don't care about the introduced whitespace as data and it made some debugging easier. This isn't always a valid approach so keep that in mind.