I have the following XML:
<response>
<error>Error Text</error>
<results>
<parent>
<dataarray>
<data>blah blah blah</data>
<data>blah blah blah</data>
<data>blah blah blah</data>
<data>blah blah blah</data>
</dataarray>
</parent>
</results>
</response>
I need to deserialize this into the following class
[XmlRoot("response")]
public class Response
{
[XmlElement("result")]
public string Error { get; set; }
[XmlElement("results")]
public MyResult Result { get; set; }
}
public class MyResult
{
[XmlArray("dataarray")]
[XmlArrayItem("data")]
public List<string> Data{ get; set; }
}
However due to the data array being within the parent element this does not work. I know i can solve this by creating another class for the parent element and put the data array into that but that seems wasteful.
Is there a way I use the above class structure?
No comments:
Post a Comment