Move shared XML generation code into ParserCore

This is the first step in refactoring the parser code

Change-Id: I4cf30100c69d913896bb20bb223b6093a35cce01