Fix add xml write. closes #2357