Don't repeat code in function parseFromXml