Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Liquid XML Objects

Liquid XML Objects

Liquid Technologies Ltd

|
2,520 installs
| (1) | Free Trial
Creates a data model based on an XML Schema (XSD), providing a strongly typed class library API for C# or Visual Basic from XSD 1.0 and XSD 1.1)

For Visual Studio 2022 support, please see:

https://marketplace.visualstudio.com/items?itemName=LiquidTechnologies.LiquidXmlObjesctVS2022

XML Data Binding Introduction

What is XML Data Binding

XML Data Binding is the process of creating an XML Data Model from an XML Schema (XSD). This XML Data Model contain strongly typed classes and properties mirroring those defined in the XML Schema. Using the XML Data Model to read and write XML documents is a quicker, easier and less error prone way of working with XML data.

Liquid XML Objects provides highly accurate conversion between XML and the generated class model. Allowing complex XML standards to be supported, and includes support for XSD 1.0 and XSD 1.1.

Generating code from an XSD

The first step is to generate an XML Data Model from your XML Schema (XSD).

This can be done Visual Studio or via the command line.

In Visual Studio simply include the XSD within your and right click the "Generate Data Binding Code" menu item, that's it your done!

Using the generated code

Once you have generated an XML Data Model, using it couldn't be simpler. We will read an XML document. This is achieved by using the LxSerializer< T> factory class, which will create an instance of our object.

De-serializing and XML document

LxSerializer<BookstoreElm> serializer = new LxSerializer<BookstoreElm>();
BookstoreElm bookstore = serializer.Deserialize(@"..\..\BookstoreSample.xml");

Then simple use the strongly typed properties to read data from the object.

Reading data from the generated classes

// Display details about the books
foreach (var book in bookstore.Book)
    Console.WriteLine($"Book : {book.Title} by {book.Author.First_Name} {book.Author.Last_Name} published on {book.Publicationdate}");

Data within the class library can be modified in the same way.

Writing data into the generated classes

// Reduce the price of all reference books
foreach (var book in bookstore.Book.Where(b => b.Genre == BookTypeCt.GenreEnum.Reference))
    book.Price = book.Price / 2;

The XML data can then be written back out using the LxSerializer we created earlier.

Serializing the classes as XML data Copy Code  
serializer.Serialize(@"..\..\UpdatedBookstoreSample.xml", bookstore);

And that's it in a nutshell. Simple, clean and easy. The generated code makes working with XML data simple and easy, whilst being extremely light weight and fast.

Learn More

Quick Start Guide

The Generated Code Explained

Generating an XML Data Model from an XSD in Visual Studio

Example : Reading XML

Example : Writing XML

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft