Using XmlSerializer

From the name you probably guessed that theXmlSerializer serializes data into XML. It gives you more control over the XML structure of the serialized data. Typical real-world examples for using this serializer would be to maintain compatibility with XML web services. It is also an easy medium to use when transmitting data using some type of message queuing (such as MSMQ or RabbitMQ).

The default behavior of  XmlSerializer is to serialize public fields and properties. Using attributes from the System.Xml.Serialization namespace, you can control the structure of your XML.

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.