Liquid XML Data Binding for .Net C#

  • Generates simple intuitive code
  • Supports XSD, XDR & DTD's
  • Unrivaled W3C XSD standard support, handles the most complex XML standards where xsd.exe would fail.
  • .Net Data Binding support code generation for C# and VB.Net, Xamarin.Android and Xamarin.iOS (C#), Silverlight (C# and VB.Net), Java, Visual Basic 6 and C++
  • Supports Fast Infoset XML compression
  • Generates HTML Documentation
  • Royalty free distribution & source

Strongly Typed Code

Liquid XML Data Binder creates simple intuitive code from your XML Schema. The code library contains strongly typed classes and collections.

Customisable Code

The generated output may also be modified within special 'Hand Coded Blocks', changes inside these blocks are persisted when the library is re-generated, allowing the library to be customised to fit the projects needs.

Standard Support

The use of XML is exploding, and with it the number and complexity of 3rd party standards. There are now 1000's of XML Schemas describing everything from Solar orbits to coffee bean quality. Because the XSD standard is complex, many XML Data Binding tools only support a sub set of it. This may be adequate for small in house schemas, but in the real world you need something that will cope with the standards that exist out in the wild. Liquid XML Data Binder has an unprecedented level of support for the W3C XSD Standard allowing it to cope with the most complex standards, just try it and see.

Get Started

Download the free 30 day trial and get started now.

A Simple Example

The following example we will use the Person.xsd, shown below to demonstrate how to read and write an XML document based on this schema.

 Source XML Schema - Person.xsd

The Person.xsd schema shown graphically using Liquid XML Studio

The model for Person.xsd
<?xml version="1.0" encoding="utf-16"?>
<!--Created with Liquid XML Studio -->
<xs:schema xmlns:xs="">
 <xs:element name="Person">
    <xs:element name="Name" type="xs:string" />
    <xs:element name="DateOfBirth" type="xs:date" />
    <xs:element minOccurs="0" name="Address">
       <xs:element name="HouseNo" type="xs:int" />
       <xs:element name="PostCode" type="xs:string" />
    <xs:element minOccurs="0" maxOccurs="unbounded" name="Car">
       <xs:element name="Make" type="xs:string" />
       <xs:element name="Model" type="xs:string" />

 Sample XML File - PersonSample.xml

This XML file conforms to the Person.xsd shown above.
<?xml version="1.0"?>
    <PostCode>WV6 6JY</PostCode>

Creating an XML document - C# Source Code 

With Liquid XML Data Binder

The code needed to create the PersonSample.xml document using Xml Data Binding.

Person p = new Person();
p.Name = "Fred";
p.DateOfBirth = new XmlDateTime(1978, 6, 26);

Address a = new Address();
p.Address = a;
p.Address.HouseNo = 7;
p.Address.PostCode = "WV6 6JY";

Car runAroundCar = new Car();
runAroundCar.Make = "Ford";
runAroundCar.Model = "Escort";

Car toyCar = new Car();
toyCar.Make = "Lotus";
toyCar.Model = "Elise";



Without Data Binding

The code needed to create the PersonSample.xml document using MSXML.

XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElmPerson = xmlDoc.CreateElement("Person");

XmlElement xmlElmName = xmlDoc.CreateElement("Name");
xmlElmName.InnerText = "Fred";

XmlElement xmlElmDOB = xmlDoc.CreateElement("DateOfBirth");
xmlElmDOB.InnerText = "1978-06-26";

XmlElement xmlElmAddress = xmlDoc.CreateElement("Address");

XmlElement xmlElmHouseNo = xmlDoc.CreateElement("HouseNo");
xmlElmHouseNo.InnerText = "7";

XmlElement xmlElmPostCode = xmlDoc.CreateElement("PostCode");
xmlElmPostCode.InnerText = "WV6 6JY";

XmlElement xmlElmCarRA = xmlDoc.CreateElement("Car");

XmlElement xmlElmRAModel = xmlDoc.CreateElement("Make");
xmlElmRAModel.InnerText = "Ford";

XmlElement xmlElmRAMake = xmlDoc.CreateElement("Model");
xmlElmRAMake.InnerText = "Escort";

XmlElement xmlElmCarToy = xmlDoc.CreateElement("Car");

XmlElement xmlElmToyModel = xmlDoc.CreateElement("Make");
xmlElmToyModel.InnerText = "Lotus";

XmlElement xmlElmToyMake = xmlDoc.CreateElement("Model");
xmlElmToyMake.InnerText = "Elise";

using (StringWriter sr = new StringWriter())
  XmlWriterSettings xws = new XmlWriterSettings();
  xws.Indent = true;

  using (XmlWriter xtw = XmlTextWriter.Create(sr, xws))

The XML Data Binding code is much easier to read, more concise and will allow errors to be detected at compile time should the data model change.

The DOM code is verbose, difficult to read, and should the data model change, the errors will only be picked up in testing.

  Reading an XML document - C# Source Code

The code needed to read the PersonSample.xml document using Xml Data Binding.

  "{0} was born {1}, and lives at {2}, {3}",

  "Cars Owned ({0})", p.Cars.Count));
foreach (Car c in p.Cars)
  string.Format(" {0}, {1}",
The code needed to read the PersonSample.xml document using MSXML.
XmlDocument xmlDoc = new XmlDocument();

XmlElement xmlElmPerson = GetFirstElement(xmlDoc);
if (xmlElmPerson == null || xmlElmPerson.Name != "Person")
  throw new Exception("Must start with Person");

XmlElement xmlElmName = GetFirstElement(xmlElmPerson);
if (xmlElmName == null || xmlElmName.Name != "Name")
  throw new Exception("Missing Person->Name");

XmlElement xmlElmDOB = GetNextElement(xmlElmName);
if (xmlElmDOB == null || xmlElmDOB.Name != "DateOfBirth")
  throw new Exception("Missing Person->DateOfBirth");

XmlElement xmlElmAddress = GetNextElement(xmlElmDOB);
if (xmlElmAddress == null || xmlElmAddress.Name != "Address")
  throw new Exception("Missing Person->Address");

XmlElement xmlElmHouseNo = GetFirstElement(xmlElmAddress);
if (xmlElmHouseNo == null || xmlElmHouseNo.Name != "HouseNo")
  throw new Exception("Missing Person->Address->HouseNo");

XmlElement xmlElmPostCode = GetNextElement(xmlElmHouseNo);
if (xmlElmPostCode == null || xmlElmPostCode.Name != "PostCode")
  throw new Exception("Missing Person->Address->PostCode");

if (GetNextElement(xmlElmPostCode) != null)
  throw new Exception("Unexpected Element found");

    "{0} was born {1}, and lives at {2}, {3}",

XmlElement xmlElmCar = GetNextElement(xmlElmAddress);
while (xmlElmCar != null)
  if (xmlElmCar.Name != "Car")
    throw new Exception("Unknown element " + xmlElmCar.Name);

  XmlElement xmlElmMake = GetFirstElement(xmlElmCar);
  if (xmlElmMake == null || xmlElmMake.Name != "Make")
    throw new Exception("Missing Person->Car->Make");

  XmlElement xmlElmModel = GetNextElement(xmlElmMake);
  if (xmlElmModel == null || xmlElmModel.Name != "Model")
    throw new Exception("Missing Person->Car->Model");

  if (GetNextElement(xmlElmModel) != null)
    throw new Exception("Unexpected Element found");

    string.Format(" {0}, {1}",

  xmlElmCar = GetNextElement(xmlElmCar);

private static XmlElement GetFirstElement(XmlNode xmlParent)
  if (xmlParent == null)
    return null;
  else if (xmlParent.FirstChild == null)
    return null;
  else if (xmlParent.FirstChild is XmlElement)
    return xmlParent.FirstChild as XmlElement;
    return GetNextElement(xmlParent.FirstChild);

private static XmlElement GetNextElement(XmlNode xmlNode)
  while (xmlNode != null)
    xmlNode = xmlNode.NextSibling;
    if (xmlNode is XmlElement)
      return xmlNode as XmlElement;
  return null;
Because the XML Data Binding code does the bulk of the parsing for you, manipulating the XML objects is just a matter of dealing with collections of objects, no need to continually check the type of an item etc.


XML Data Binding makes it significantly easier to deal with XML documents from within your code, resulting in less code, which is simpler to read and maintain.

As the generated class library is strongly typed, it forms a kind of template for the developer, ensuring that the data created conforms to the underlying XML Schema.

The maintenance phase of a project also befits as XML Data Binding allows any errors introduced because of changes in the data model to be caught early at compile time, unlike weakly typed DOM trees, which will give no indication of a problem until runtime. These kinds of changes can be a major cause of bugs which can only be caught in testing. Being able to identify these at compile time can save huge amounts of time and effort.