refactor XML parsing using SAX parser