Add error handling when parsing XML response to ensure validity.