我需要处理某些xml,无法从中反序列化对象列表.以下是xml:
<catalog>
<item>
<id>18338517</id>
<note label="Name ">Gear xyz</note>
<note label="Size ">10</note>
<note label="Source">Store xyz</note>
<relation weight="100">
<type>External</type>
<id>123</id>
<name>Mcday</name>
</relation>
<relation weight="99">
<type>Internal</type>
<id>234</id>
<name>Mcnight</name>
</relation>
</item>
<item> ..... </item></catalog>
Run Code Online (Sandbox Code Playgroud)
以下是我的课
[XmlRoot("catalog")]
public class Catalog
{
[XmlArray("item")]
[XmlArrayItem("item", typeof(Item))]
public Item[] item{ get; set; }
}
[XmlRoot("item")]
public class Item
{
[XmlElement("id")]
public string id { get; set; }
[XmlArrayItem("note", typeof(Note))]
public Note[] note { get; set; }
[XmlArrayItem("relation", typeof(Relation))]
public Relation[] relation { get; set; }
}
[Serializable]
public …Run Code Online (Sandbox Code Playgroud)