I would like to deserialize a HTML table into an object. But with the following code, it expects to see <Rows> as the parent of <tr>‘s and <Cells> as the parent of <td>‘s. I want to keep this class structure. Am I missing any attribute declaration?
<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; }
}
Try setting the attributes as shown below. Note that you’ll have to change the type of
Valueon theCellclass fromobjecttostring.