The Liquid XML Objects code generator creates a very light weight set of classes attributed with meta data to describe the underlying XML structure.
Consider the following schema
Sample XML Schema |
Copy Code
|
---|---|
<?xml version="1.0" encoding="utf-8" ?> <!--Created with Liquid Studio (https://www.liquid-technologies.com)--> <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Root"> <xs:complexType> <xs:sequence> <xs:element name="MyElement" type="xs:boolean" /> <xs:element name="MyElementCollection" type="xs:double" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="MyAttribute" type="xs:int" /> </xs:complexType> </xs:element> </xs:schema> |
Which produces the following code
Sample Generated Code |
Copy Code
|
---|---|
public partial class RootElm { public System.Int32 MyAttribute { get; set; } public RootElm.RootSeq Seq { get; set; } = new RootElm.RootSeq(); public partial class RootSeq { public System.Boolean MyElement { get; set; } public List<System.Double> MyElementCollection { get; } = new List<System.Double>(); } } |
Lets examine this is more details.
This is a very basic example, but you can see that the generated code mirrors the structure of the XSD very closely, this includes representing the xs:sequence within the model. This makes it possible to provide an extremely accurate representation of the XML data within the class model.
The LxSerializer class is used to serialize and de-serialize the data from the generated classes