如何序列化这个XML在.NET中(阵) [英] How to serialize this Xml in .NET (array)
本文介绍了如何序列化这个XML在.NET中(阵)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要的XML看起来像这样
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;
}
但是,这给了我的Xml哪里栏项目被包装在酒吧元素中。我应该如何界定我的自定义XMLATTRIBUTES所以我得到的XML结构,我需要?
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?
推荐答案
我必须要解决类似的东西昨天,这是该解决方案对我来说:
I had to solve something similar yesterday, and this was the solution for me:
[XmlRoot("foo")]
public class Foo
{
[XmlElement("bar")]
public List<Bar> myBars;
}
这篇关于如何序列化这个XML在.NET中(阵)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文