Page 1 of 1

Find optimum nested level in XML generation

Posted: Sun Sep 14, 2025 1:20 pm
by Niranjan
Hello All,

I have a set of complex xsd files where there are imports/includes across all the files. I am trying to generate a sample xml file using these xsd files from "Generate Sample XML Files" option. The aim is to generate the sample xml file, paste the xml in Visual Studio 2022 as class, generate a dll (class library) and to deserialize another xml (with actual data) which was generated using same xsds. The generated .cs file also is used in other classes in the project.

I am at wits end as I am not able to get the right configuration for "Generate Sample XML Files" as for every combination I get different issues. Sometimes instead of collections I get objects (setting "preferred number of options to 2 generated List in .cs file but the classes repeat), sometimes elements go missing, file size too big etc.

The user manual says discardOptionalElementsAfterNestedLevel can generate large files which is correct. How do I check the optimum setting for this variable?

Image shows file sizes generated for different discardOptionalElementsAfterNestedLevel settings

Capture.JPG
Thanks in advance.
Niranjan