1

I'm currently reading about serialization and C# attributes related to serialization (XmlRoot, XmlElement, XmlArray, ...).

I want to output something like this:

<root>
    <a>...</a>
    <b>...</b>
    <c>...</c>
    <c>...</c>
    <c>...</c>
</root>

(where the c element occurs several times)

But I don't get how to have multiple c without having them inside a specific "array/list node".

Because I really don't want that:

<root>
    <a>...</a>
    <b>...</b>
    <cList>
        <c>...</c>
        <c>...</c>
        <c>...</c>
    </cList>
</root>

How can this be achieved?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Serge
  • 6,554
  • 5
  • 30
  • 56
  • It's trivial: just don't add a `` node. (And a hint: look at XElement et al as an alternative to XmlElement) – H H Jun 14 '13 at 07:48

1 Answers1

6

Try it like this:

[XmlElement("c")]
public List<c> cList { get; set; }
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55