c# - Serialize field as attribute of an element -


i have

[xmlroot("root")] class person {   [xmlattribute("name")]    public strig name {get;set;} } 

after serialization get:

<root name="..."> </root> 

any simple way get

<root>   <general name="..."> </root> 

?

options me are: make other class, using ixmlserializable, etc

it's posible have below ?

// code not valid [xmlelement("general")] [xmlattribute("name")]  public strig name {get;set;} 

to element inside need use xmlelement attribute. if create 'general' class containing xmlattribute("name") property. can add person class.

[xmlroot("root")] class person {     [xmlelement("general")]     public general general {get; set;} } class general {     [xmlattribute("name")]      public strig name {get;set;} } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -