Liquid Fast Infoset for .Net - Examples

.Net Integration Examples

Liquid Fast Infoset for .Net provides an intuitive API that integrates with the .Net framework XML classes. The FIReader and FIWriter classes derive from XmlReader and XmlWriter respectively and so can be seamlessly integrated within your application in place of existing .Net classes such as XmlTextReader and XmlTextWriter.

System.Xml.XmlDocument

The XmlDocument class within the .Net Framework represents an XML document implemented as a DOM tree.

These examples show how Liquid Fast Infoset for .Net easily integrates with the XmlDocument class in the same way as the .Net classes XmlTextReader and XmlTextWriter, allowing us to convert between the Xml document and Fast Infoset document formats with just a few lines of code.

Example: Convert an XML document to a Fast Infoset document

CopyC#
using System.Xml;
using LiquidTechnologies.FastInfoset; string xmlFilename = new string(@"c:\MyFile.xml"); string finfFilename = new string(@"c:\MyFile.finf"); XmlDocument doc = new XmlDocument(); // Read a standard XML document file into an XmlDocument using XmlTextReader XmlReader reader = XmlReader.Create(new XmlTextReader(xmlFilename), null); doc.Load(reader); reader.Close(); // Write the XML document to a file encoded as Fast Infoset using FIWriter XmlWriter fiWriter = XmlWriter.Create(new FIWriter(finfFilename)); doc.WriteTo(fiWriter); fiWriter.Close();

Example: Convert a Fast Infoset document to an XML document

CopyC#
using System.Xml;
using LiquidTechnologies.FastInfoset; string xmlFilename = new string(@"c:\MyFile.xml"); string finfFilename = new string(@"c:\MyFile.finf"); XmlDocument doc = new XmlDocument(); // Read a Fast Infoset encoded file into an XmlDocument using FIReader XmlReader fiReader = XmlReader.Create(new FIReader(finfFilename), null); doc.Load(fiReader); fiReader.Close(); // Write a standard XML document to file using XmlTextWriter XmlWriter writer = XmlWriter.Create(new XmlTextWriter(xmlFilename, Encoding.Default)); doc.WriteTo(writer); writer.Close();

 

 

 

 

 

Products | Free XSD Editor | Free XML Editor | XML Data Binding | Download | Purchase | Support | Contact Us
©2006 Liquid Technologies Limited. All rights reserved. Privacy Policy