Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XML解析-带值类的数组_C#_Xml_Parsing_Serialization - Fatal编程技术网

C# XML解析-带值类的数组

C# XML解析-带值类的数组,c#,xml,parsing,serialization,C#,Xml,Parsing,Serialization,我有一个XML文件,看起来像这样: <complex> <complex>Value</complex> <complex> <field>Value</field> </complex> </complex> [XmlElement] public List<Field> field { get; set; } public class Fie

我有一个XML文件,看起来像这样:

<complex>
    <complex>Value</complex>
    <complex>
       <field>Value</field>
    </complex>
</complex>
[XmlElement]
public List<Field> field { get; set; }


public class Field
{

[XmlAttribute]
public string name;

[XmlAttribute("ref")]
public string reference;

[XmlText]
public string value;

}

价值
价值
现在,field的类如下所示:

<complex>
    <complex>Value</complex>
    <complex>
       <field>Value</field>
    </complex>
</complex>
[XmlElement]
public List<Field> field { get; set; }


public class Field
{

[XmlAttribute]
public string name;

[XmlAttribute("ref")]
public string reference;

[XmlText]
public string value;

}
[XmlElement]
公共列表字段{get;set;}
公共类字段
{
[XmlAttribute]
公共字符串名称;
[xmldattribute(“ref”)]
公共字符串引用;
[XmlText]
公共字符串值;
}
我想解析复合体的值,以及复合体的子对象

我假设复合体既是一个数组,又是其他东西

如果您有任何意见,我将不胜感激

使用VisualStudio的“将XML粘贴为类”会产生以下结果(在我将其变得更加简洁之后):


这就是你想要的吗?

你的问题不清楚,你应该提供更多的信息。