Replace own database layer implementation

Replace own database abstraction layer for Doctrine's DBAL.
Also output XML using formatOutput of DOMDocument.