in reply to

A quick question. I'm wondering why you were not able to (or didn't want to) use an XML processor for this? IIRC XSD files are XML compliant so you could have used a DOM processor for easy re-org of the tree before spitting it back out.

You could even use XSLT on your schema to produce a different output (though in this case that may not be relevant ;) ).

Cheers :)