-_- BAT -_-

成长了吧?

 

C# xml序列化与反序列化(转)

以下为将被序列化的类Entity:

[XmlRoot("Root")]
public class Entity
{
[XmlAttribute(AttributeName = "Attr1")]
public string Attribute1;

[XmlElement("SecondLevel")]
public SecondLevel SecondLevel;

public override string ToString()
{
return Serializer.Serialize(this);
}
}

public class SecondLevel
{
[XmlElement("ThirdLevel")]
public List<ThirdLevel> ThirdLevel;
}

public class ThirdLevel
{
[XmlAttribute(AttributeName = "Attribute1")]
public string Attribute1;

[XmlAttribute(AttributeName = "Attribute2")]
public string Attribute2;

[XmlElement("Ele1")]
public Element Ele1;
}

public class Element
{
[XmlAttribute(AttributeName = "Attr1")]
public string Attribute1;

[XmlText]
public string Value;
}

posted on 2020-07-22 18:41  -_-BAT-_-  阅读(118)  评论(0)    收藏  举报

导航