re: Xml Serialization


 

hi people,

 

i losing mind on problem:

 

here classes:

 

code snippet

[xmlroot("baseflightsector")]

[xmlinclude(typeof(flightsector))]

public class baseflightsector{}

[xmlroot("flightsector")]

public class flightsector : baseflightsector{}

[xmlroot("flightsectors")]

public class flightsectors : list<flightsector>{}

 

 

 

 

i proceed serialize these classes:

code snippet

flightsectors fs = new flightsectors();

flightsector f = new flightsector();

fs.add(f);

using (stringwriter sw = new stringwriter())

{

xmlserializer xs = new xmlserializer(typeof(flightsectors));

xmlserializernamespaces ns = new xmlserializernamespaces();

ns.add(string.empty, string.empty);

xs.serialize(sw, fs, ns);

console.writeline(sw.tostring());

}

 

 

 

and get:

 

flightsectors

flightsector/

flightsectors

 

when want:

 

flightsectors

flightsector /

/flightsectors

 

 

what's going on?  sorry poor xml keeps disappearing.

 

as always, in advance,

 

koder

 

 

add xmltype attribute flightsector

 

[xmltype(typename = "flightsector")]
public class flightsector : baseflightsector { }

 

-shreyas



Archived Forums A-B  >  ASMX Web Services and XML Serialization



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'