c# - Change array element name without flattening with XmlSerializer -


i have following code:

[serializable] [xmlroot("database")] public class sqldatabase {     public list<sqltable> tables { get; private set; } } 

if use xmlserializer without custom attribute, generated xml persists list hierarchy:

<database>   <tables>     <sqltable name="table1" />     <sqltable name="table2" />   </tables> </database> 

however, i want change element name "sqltable" "table". tried use xmlelement attribute on list

[serializable] [xmlroot("database")] public class sqldatabase {     [xmlelement("table")]     public list<sqltable> tables { get; private set; } } 

the name changed hierarchy flattened:

<database>   <table name="table1" />   <table name="table2" /> </database> 

then tried xmlarray attribute, changes name of list not elements within:

[serializable] [xmlroot("database")] public class sqldatabase {     [xmlarray("foo")]     public list<sqltable> tables { get; private set; } } 

results in

<database>   <foo>     <sqltable name="table1" />     <sqltable name="table2" />   </foo> </database> 

i tried combine these 2 , there exception saying can't used together.

so question is, is there simple way change element name without flattening hierarchy?


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -