Further refactored xml parser