Okay, why did nobody mention XML::Compile? (Well, besides stuffing it in a list above.) It uses XML::LibXML directly. It's a mature and well-supported set of modules. It creates hash trees, and it uses those to create XML from schema files.
Why isn't, like, 100% of the Perl community using this?