Improved the error messages for XML encoding by indicating which attribute is in error when an unexpected type is encountered.