Understanding Output

May 12, 2014 at 3:16 PM
If I use the .Net XML Serializer on this class:
public class Tester
{
    public string Name { get; set; }
    public int Age { get; set; }
    public DateTime Birth { get; set; }
    public DateTime Death { get; set; }
}
It returns the following output:
<?xml version="1.0" encoding="utf-8"?>\
<Tester xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>One</Name>
<Age>40</Age>
<Birth>1974-01-01T00:00:00</Birth>
<Death>0001-01-01T00:00:00</Death>
</Tester>

When I serialize the same class and data using Sharp Serializer I get this output:

<Complex name="Root" type="ConsoleApplication3.Tester, ConsoleApplication3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<Properties>
<Simple name="Name" value="One" />
<Simple name="Age" value="40" />
<Simple name="Birth" value="01/01/1974 00:00:00" />
<Simple name="Death" value="01/01/0001 00:00:00" />
</Properties>
</Complex>

Can I get the XML Serialization output from Sharp Serializer? In other words, can I get the element name to be the Field Names instead of the XSD Data Types?

Thanks for any help.
Coordinator
May 12, 2014 at 5:58 PM
hi, there is no possiblity for storing SharpSerializer data as the XmlSerializer XML. SharpSerializer serializes additional information like type information of inherited objects XmlSerializer is provided with this type information in its Serialize method.

if you serialize simple classes without their inheritance - I would suggest using XmlSerializer.