refactoring of the xml2build function