c# - Serialization of list inside parent node (flattening of collection) -
i have generate xml structured (using .net serialization):
<person> <name>john</john> <address>address1</address> <address>address2</address> <address>address3</address> </person>
currently, have class person
name list<string> addresses
inside.
i think xmlserializer
create default <addresses>
node holds every address child element, get, instead:
<person> <name>john</john> <addresses> <address>address1</address> <address>address2</address> <address>address3</address> </addresses> </person>
that is not need.
my question is, possible flatten addresses inside <person>
?
use xmlelement instead of xmlarray code below. xmlarray adds layer of tags.
[xmlroot("person")] public class person { [xmlelement("name")] public string name {get; set;} [xmlelement("address")] public string[] address {get; set;} }
Comments
Post a Comment