variable xmlData is redundant. You can just write 'return  (T)obj'