// This is my xml data I am trying to map this to my .net classes. By converting XML to json and json back to C# classes.
string xml = @\"
Once you have serialized the XML into JSON, copy the JSON and generate the classes for it by referring this answer. Here are the classes:
public class Rootobject
{
public Reporttemplate ReportTemplate { get; set; }
}
public class Reporttemplate
{
public Page[] Page { get; set; }
}
public class Page
{
public string Id { get; set; }
public string LayoutId { get; set; }
public Section[] Section { get; set; }
public string text { get; set; }
}
public class Section
{
public string Id { get; set; }
public string Body { get; set; }
public object Content { get; set; }
}
Then deserialize the JSON into those classes:
var xmldoc = new XmlDocument();
xmldoc.LoadXml(xml);
var fromXml = JsonConvert.SerializeXmlNode(xmldoc);
var fromJson = JsonConvert.DeserializeObject<Rootobject>(fromXml);