Have to do recursive loop to find all the nested properties from a class till the last property and initialize them with a default value, if string then update with string.empty, if Enum then update with index[0], if int then update with 0, if custom type of that property then initialize it. Finally I will get an object with values till the end property of the main class.
So beyond that I can do serialize to get the xml.
I have added 3 images.
First image denotes the main class. I will pass the class name to the new method, that method have to find out the nested properties, which is second image and third image shows the 2nd nested child property which is enum.