Deduplicating the XML parsing code