I realize that there is a similar question here: How to deserialize xml to object
But this is not the same. In my case the object I am trying to deserialize is not xml, it is a class that represents data I would like to assign to my xml.
I have xml data that looks like this:
<?xml version="1.0"?>
<grouping>
<item>
<book>book text</book>
<title>title text</title>
<genre>
<subitem>subitem name</subitem>
</genre>
</item>
<part>
<name>Doe, John/name>
<description>desc text</description>
<detail>detail text</detail>
</part>
</grouping>
I have class that looks like this:
public class DataRow{
public string book;
public string title;
public string subitem;
public string name;
public string description;
public string detail;
}
I'm deserializing my data base data to the class so that I have an instance of it such as dr
. I can now do dr.book
,dr.title
, etc...
How can I deserialize my DataRow class instance (dr
) to the XML?