As far as I remember, neither XML::DOM nor XML::LibXML (or, to be exact, the respective "Document" subclasses) require
a DTD. But you can verify your document against a DTD after you're done building (e. g. XML::LibXML::Document has a method is_valid () which accepts an XML::LibXML::Dtd object).