Refactored XML export.