Building a complete xml doc instantiating only one nested element

Dec 12, 2014 at 9:36 PM
I have an xsd with some deeply nested elements. For example:

I would like to create a complete XML by filling in just the leaf elements and have the generated code deal with the creation of the superordinate elements, in such a way that on entering values for the leaf units I could obtain something like

But the fact is that if I invoke the xsd2code generated class Vital_SignsBlood_pressureSistolicMagnitude, instantiate the class and add a value, I get, as a result of serialization, something like


which isn't very useful.

In order to reproduce the whole xml structure I must create each class and include a created nested class in it, something which is quite complicated.

Is there something which might allow me to do something on the lines of

var vs = new Vital_signs();
vs.BloodPressure.Sistolic.Magnitude = 120;
vs.BloodPressure.Sistolic.Units = "mmHg";

the classes for which could be produced automatically?

I understand this might be difficult when it comes to adding lists and the like, but it would be most useful. Creating a class for every level is quite cumbersome in case of really big xsd's. There is probably some way of doing this which I am unaware there?