I wish to define classes that will produce the following xml using System.Xml.Serialization.XmlSerializer. I am struggling to get the items list, with attributes that does not contain a child ‘container’ element for ‘item’ elements.
<?xml version="1.0" ?>
<myroot>
<items attr1="hello" attr2="world">
<item id="1" />
<item id="2" />
<item id="3" />
</items>
</myroot>
with
XmlSerializerthings are either lists or they have members. To do that you need:with example:
which generates:
you can remove the
xsi/xsdnamespace aliases if you want, of course.