Question

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?

Was it helpful?

Solution

Try it like this:

[XmlElement("c")]
public List<c> cList { get; set; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top