refactored a message displaying code and implemented elegant error handling for failed XML validation.