我有一个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;
}
我想解析复杂的价值以及复杂的子女。
我认为复合体既是数组又是其他东西?
我很感激任何意见!
答案 0 :(得分:0)
使用Visual Studio&#34;将XML粘贴为类&#34;产生这个(在我把它变得更简洁之后):
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class complex {
[System.Xml.Serialization.XmlElementAttribute("complex")]
public complexComplex[] complex1 { get; set; }
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class complexComplex {
public string field { get; set; }
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text { get; set; }
}
}
这就是你想要的吗?