Modify the XML creation flow for register for better code reuse