[英]C# XML several occurrences of a same element
I'm currently reading about serialization and C# attributes related to serialization (XmlRoot, XmlElement, XmlArray, ...). 我目前正在阅读有关序列化和与序列化相关的C#属性(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) (其中c
元素出现多次)
But I don't get how to have multiple c
without having them inside a specific "array/list node". 但是,如果不将多个c
放在特定的“数组/列表节点”中,我将无法获得多个c
。
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? 如何做到这一点?
Try it like this: 像这样尝试:
[XmlElement("c")]
public List<c> cList { get; set; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.