Home  /  Blog  /  Documentation  /  Code Generator   /  Settings  /  Serialization  /  XML Serialization

Extensible Markup Language

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.

IndentChars

This settings indicates the indentation level for XML formatting.

NewLineOnAttributes

This setting indicates wether or not each attribute is positioned on a new line. 

OmitXMLDeclaration

This setting indicates the status of the XML declaration; true to omit the XML declaration; otherwise, false. The default is false, an XML declaration is written.

SchemaLocation

The xsi:schemaLocation attribute locates schemas for elements and attributes that are in a specified namespace. Its value is 
is a sequence of alternating namespace URI's followed by relative or absolute URL's where the schema for that namespace can be found. You can find a step by step guide detailing the use of this settings in our 

xmlns

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

Terms & privacy

Terms of uses · Privacy policy 

Contact

CodeNGine Technologies, 19 Avenue, de la gare, 34770 Gigean, France. SIRET: 85257252800010, VAT : FR 62852572528
codengine.technologies@xsd2code.com

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