I want to achieve XML in this style using C# XMLseralizer
<state id="s1">val<state />
But I got this
<state id="s1">
<val>1<val />
<state />
with the following code
[XmlType("state")]
public class mystate
{
[XmlAttribute("id")]
public string id;
public int val;
}
Anyone has hints? Thanks.
Just add the
XmlTextattribute to the member you want as the element content, like so: