Sunday, January 23, 2011

List< T> as XmlArray


[System.Xml.Serialization.XmlRoot(ElementName = "user")]
public class User
{
[System.Xml.Serialization.XmlElement(ElementName = "id")]
public string ID { get; set; }

[System.Xml.Serialization.XmlArray("logs")]
[System.Xml.Serialization.XmlArrayItem("log")]
public List< Log> Logs { get; set; }
}

public class Log
{
[System.Xml.Serialization.XmlElement(ElementName = "no")]
public int Number { get; set; }

[System.Xml.Serialization.XmlElement(ElementName = "level")]
public string LogLevel { get; set; }
}

We could then deserialize an xml like the following into a User object.


1344166


1
Info


2
Debug



1 comment:

Unknown said...


Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.

www.imarksweb.org