XML serialization of list

后端 未结 2 1593
無奈伤痛
無奈伤痛 2020-12-19 09:04

I am serializing an object to XML. I have something like this:

Class A
{
   public string propertyA1  { get; set; }
   public List bList { get; set         


        
相关标签:
2条回答
  • 2020-12-19 09:34

    Also you can try XmlArrayItemAttribute. Please refer below links.

    http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx

    http://msdn.microsoft.com/en-us/library/2baksw0z(v=vs.71).aspx

    0 讨论(0)
  • 2020-12-19 09:48

    Add the attribute [XmlElement] to treat the collection as a flat list of elements:

    Class A
    {
       public string propertyA1  { get; set; }
       [XmlElement("B")]
       public List<B> bList { get; set; }
    }
    

    for more info click here

    0 讨论(0)
提交回复
热议问题