I have this list property in a class and I need to decorate it with the correct xml attributes to get it in the form:



<Attachments>
<Documents>
<Document>
the DocumentType nodes...
</Document>
<Document>
the DocumentType nodes...
</Document>
</Documents>
</Attachments>


when I serialize the object. Here is the declaration of the list property within the class:



[XmlArrayItem("Documents", IsNullable = false)]
[XmlArrayItem("Document", IsNullable = false, NestingLevel = 1)]
public List<DocumentType> Attachments
{
get
{
return this._attachments;
}
set
{
this._attachments = value;
}
}


Currently what I get is this:



<Attachments>
<Documents>
the DocumentType nodes...
</Documents>
<Documents>
the DocumentType nodes...
</Documents>
</Attachments>


Its clear to me that the "Documents" node I want should be declared something other than an XmlArrayItemAttribute. The name of the list can not change. Help me Obi Wan Kenobi, you're my only hope.


No comments:

Post a Comment