Ok, So I am serializing a class into xml to be sent as an HttpResponse. Part of the data is a list of 'states', and I just can't figure out how to format it they way I need it to be.
Right now the xml response looke like so:
<user id="x" date="x" ...>
<state>
<state name="Email" />
<Value>email@mail.com</Value>
</state>
</state>
<state>
<state name="Level" />
<Value>0</Value>
</state>
</state>
</user>
I don't want elements within one element, and to not be its own element, but the value of the state element. I wanted it to look like
<user id="x" date="x" ...>
<state name="Email">email@email.com</state>
<state name="Level">0</state>
</user>
right now my classes are:
[XmlRoot("user")]
public class User {
[XmlAttribute]
public int Id { get; set; }
[XmlAttribute]
public DateTime Date { get; set; }
[XmlArray]
public List<State> State { get; set; }
}
public struct State {
[XmlAttribute]
public string Name { get; set; }
public string Value { get; set; }
}
Could someone show me what I am doing wrong? I cannot change the expected output, the service that is receiving these responses is preexisting and out of my control.
Thanks.