Write xml parsing logic