There are various data persistence libraries for Lua as well, many are described at the Lua user's wiki. The page on XML has information that could help.
The nice folks over at the Kepler project have generators for HTML which can be used for generating valid XML.
There is also cosmo which is a generalized template framework that can be used to generate XML (among other things).
Edit:
I understand the concern for templates not necessarily providing guarantees that the output remains well formed. I'm pretty sure that the authors of Cosmo would be unhappy if a well-formed template ever produced a mal-formed document, but there is still the issue of properly quoting the content. In the contexts where I've used it, this hasn't been an issue for me, but I also haven't been working from untrusted source text.
There are also projects posted at LuaForge that may be useful:
Lua Element Tree maps an XML document to and from a tree of tables. It uses Expat for reading, and claims to generate valid XML when writing.
LuaSOAP Includes XML generation and parsing sufficient for SOAP transactions. If you decide to write your own generator, this might be a good starting point for a limited dialect such as RSS or ATOM.
Also, I know I've seen a project that implemented a complete DOM for HTML documents and supported both parsing and document generation, but I can't remember its name or locate it today at LuaForge.
Edit 2: Here's another package that I hadn't noticed before, even though it is included in Lua for Windows: LuaXML. It maps between XML and nest of Lua tables, and can both read and write XML.