Я создаю объект для сериализации в xml: подробности этого объекта, как показано ниже:
[XmlRoot(ElementName="trx")]
public class OTrx{
[XmlElement("body")]
public OBody Body {get;set;}
}
, и это класс OBody:
public class OBody {
[XmlElement("list")]
public Olist list {get;set;}
}
, класс Olist:
public class Olist {
[XmlAttribute("h")]
public string h {get;set;}
[XmlAttribute("colcnt")]
public string list {get;set;}
[XmlAttribute("list")]
public stringlist {get;set;}
[XmlElement("row")]
public List<ORow> RowList {get;set;}
}
класс ORow:
public class ORow{
[XmlElement("col")]
public List<OCol> ColList {get;set;}
}
класс OCol:
public class OCol{
[XmlText]
public string Text {get;set;}
public Ocol(string val){
this.Text=val;
}
}
и мне нужен вывод:
<trx>
....
<body>
<list h="a,b,c,d,e" colcnt="5" rowcnt="5">
<row>
<col>value1</col>
<col>value2</col>
<col>value3</col>
<col>value4</col>
<col>value5</col>
</row>
<row>...</row>
<row>...</row>
<row>...</row>
<row>...</row>
</list>
</body>
</trx>
Я отлаживаюкод, это показывает, что исключение происходит в списке, когда я комментирую этот список, сериализация проходит успешно, как:
<row/><row/><row/><row/><row/><row/><row/><row/>
</list></body></trx>
Скажите, пожалуйста, в чем я не прав?