XML processing refactoring