samedi 1 août 2015

Serialize object as element with value of its field

I've got the next issue. I have a class which needs to be serialized, it has the only 1 field to store a value:

public class Element
{
     public int Value { get; set; }
}

And it is saved as(btw: it's not a root element):

<Element>
     <Value>123</Value>
</Element>

However I need to get a bit another xml:

<Element>123</Element>

Serialization is performed using System.Xml.Serialization.XmlSerializer. Is there any possibility to omit the Value-element and pass its value to Element?

I will be very grateful for any kind of help.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire