Extensible Markup Language

Serialization is the process of converting an object into an easily transportable data stream in memory or on disk. For example, you can serialize an object and transport it over the Internet via HTTP between a client and a server. At the other end, deserialization reconstructs the object from the data stream.

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The World Wide Web Consortium's XML Specification and several other related specifications define XML. The design goals of XML emphasize simplicity, generality, and usability across the Internet. It is a textual data format with strong support via Unicode for different human languages. Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structures such as those used in web services.

In this guide we will learn how to serialize an object to the XML format :
XML serialization serializes only the public fields and property values of an object in an XML data stream. XML serialization does not include type information.

xsd2code++ proposes to automatically generate the attributes to serialize your objects so that they correspond 100% to the original schema.

To enable XML serialization, please refer to the common elements for serialization. This page details the options that are specific to XML serialization.

For illustration purposes, we will use the XSD schema example which can be found in the introduction page of the documentation.

To serialize with XML, you just have to choose it in the xsd2code options:

Options that need to be enabled
Here's a section of the code that should be generated
Image showing default settings c# generated from xsd schema

Once you've ran the xsd2code generation to completion you will have the c# class that will correspond to the shown schema, depending on the chosen settings you might have less or more than you expected, we will now see some of these settings 

XML Settings

Formating XML

This parameter defines whether the XML file will be on a single line or formatted.


Indicates the indentation level for XML formatting.


Indicates that each attribute is positioned on a new line. 


true to omit the XML declaration; otherwise, false. The default is false, an XML declaration is written.


How to referencing a Schema in schemaLocation


xmlns means "XML name space". This option allows to define it in the XML header.

Terms & privacy

Terms of uses · Privacy policy 


CodeNGine Technologies, 19 Avenue, de la gare, 34770 Gigean, France. SIRET: 85257252800010, VAT : FR 62852572528

About the company

CodeNGine Technologies is software company based in the South of France that provides an advanced productivity code generation tool to developers using XML and JSON

Copyright © 2021 CodeNGine Technologies

An error has occurred. This application may no longer respond until reloaded. Reload 🗙