How to serialize this Xml in .NET (array)

Posted by Morri on Stack Overflow See other posts from Stack Overflow or by Morri
Published on 2010-05-28T10:06:57Z Indexed on 2010/05/28 10:11 UTC
Read the original article Hit count: 167

Filed under:
|

I need Xml that looks like this

<foo>
  <bar ... />
  <bar ... />
</foo>

And currently have the following class structure :

[XmlRoot("foo")]
public class Foo
{
  [XmlArrayItem("bar")]
  public List<Bar> myBars;
}

But this gives me Xml where bar items are wrapped inside a bars element. How should I define my custom XmlAttributes so I'd get the Xml structure I need?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about xml-serialization