The current version of DataMapper (0.9.1) contains to_xml methods that produce invalid (no declaration), not indented and weird (for collection of resources) XML.
There might be someone working on a better version (don’t know, didn’t get a response on my comment on the ticket), but if you need something useful now, you can use my monkeypatch: This is the code and the spec.
I didn’t feel like the following comment from the original to_xml_spec.rb was needed in my fix:
# # ==== enterprisey XML #
Or was it?