【发布时间】:2011-12-08 03:56:04
【问题描述】:
我想将一个 HTML 表格反序列化为一个对象。但是使用下面的代码,它希望看到<Rows> 是<tr> 的父级,而<Cells> 是<td> 的父级。我想保持这种班级结构。我是否缺少任何属性声明?
<table>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
public class Table
{
[XmlArrayItem("tr")]
public List<Row> Rows { get; set; }
}
public class Row
{
[XmlArrayItem("td")]
public List<Cell> Cells { get; set; }
}
public class Cell
{
public object Value { get; set; }
}
【问题讨论】:
标签: c# xml-serialization