Consider the following XML:
<elements>
<element attribute="value1">
<or>
<subelement attribute="value2" />
<subelement attribute="value3" />
</or>
</element>
<element attribute="value">
<and>
<subelement attribute="value4" />
<subelement attribute="value5" />
<or>
<subelement attribute="value6" />
<subelement attribute="value7" />
</or>
</and>
</element>
</elements>
Note that the following is also valid:
<elements>
<element attribute="value1">
<subelement attribute="value2" />
</element>
</elements>
And so is this:
<elements>
<element attribute="value1">
<and>
<or>
<subelement attribute="value2" />
<subelement attribute="value3" />
</or>
<or>
<subelement attribute="value4" />
<subelement attribute="value5" />
</or>
</and>
</element>
</elements>
(The above example would equate to (value2 or value3) AND (value4 or value5)
I tried using xsd.exe to create a XSD file from the XML and then a .cs class but it was not sufficient for my needs as I need something that can have an arbitrary depth.
How would I model this in C# as classes? I'm thinking perhaps along the lines of some sort of fluent builder pattern?
Thanks,
Richard
P.s. Anyone who can come up with a way to validate the rules created by such a class structure gets a /hug :)