Refactored XML export
See #48 #52 and #23