Patrick Desjardins
Patrick Desjardins

Reputation: 140833

C# Serialization with control over Attribute and Element without System.Serialization?

I need to transform quickly some object into an XML string. If my project would not been in Silverlight, I would simply use the [Serializable] attribute with [XmlElement] and [XmlAttribute]. Unfortunately, this is not available in Silverlight. I can't use DataContract because it does not give the control of if the property need to be attribute or element tag.

So, what is my other option? I can do manually the XML using Linq-To-Xml but is there anything else more fast?

Upvotes: 1

Views: 81

Answers (2)

AnthonyWJones
AnthonyWJones

Reputation: 189457

Another option is to use System.Xml.Serialization.XmlSerializer .

Upvotes: 1

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56172

In terms of performance, XmlWriter (fast, non-cached, forward-only) with self-implemented serialization is preferable.

Upvotes: 1

Related Questions