Adds error handling in GetObjectFromXML