fix and improve xml rendering