classes like these two
[XmlRoot("Root")]
public class VcRead
{
[XmlElement("item")]
public string[] Items;
[XmlElement("amount")]
public int Count;
}
public class KeyItem
{
[XmlAttribute("id")]
public int ID;
[XmlAttribute("name")]
public string Title;
}
now,i wanna use reflection to get all fields and their Xml Mark.
it’s easy to get the fields’ name and their values.
but,how to get the XmlElement’s value,such as “amount” in
[XmlElement("amount")]
public int Count;
To get element name from
XmlElementAttribute(same approach forXmlAttributeAttribute):Also keep in mind that your classes have public fields instead of properties.