refactor, merge GetXMLCode functions.