Fix bug where we were generating invalid XML