Is there anyway to add a XML Root Element or "Wrapper" in the XmlSerializer when I serialize an object?
The XML I am looking for would be something like this:
<Groups>
<Group method="ModifySubGroups" ID="1234" PIN="5678">
<SubGroup action="Delete" number="95">
<Name>Test</Name>
</SubGroup>
</Group>
</Groups>
I have two classes, Group and SubGroup. Group contains a generic list of SubGroups. It works great, but I don't have the XML Root "Groups". Using the two classes Group and SubGroup produces this:
<Group method="ModifySubGroups" ID="1234" PIN="5678">
<SubGroup action="Delete" number="95">
<Name>Test</Name>
</SubGroup>
</Group>
The only way I could get it to work was to create another class "Groups" that contained Group. So now I have three classes, Groups, Group, and SubGroup. Groups contains Group and Group contains SubGroup.
Any other ideas?