I've used XML::Writer to write large files - it has a simple interface and makes it hard to write a file that won't parse. If you've got more complex requirements you can use XML::SAX with XML::SAX::Writer to write large documents without holding them in memory. That would let you validate as you write with XML::Validator::Schema, for example.