Controlling Validation


Sometimes you may want read or write XML that is not completely valid against the XSD schema. There are a number of rational's behind this, you may want to save a half completed document, then re-load it, or a 3rd party may supply you data that is not quite valid. Whatever your reason, this section describes the control you have over the validation when reading and writing XML.

See links below for full API descriptions.

Reading XML

The following examples show how to ignore Unknown Attributes and Elements when reading in XML from a file. This may be useful if a customer send XML that is not valid against the schema, but you still want the ability to process the document.

Note: When the document is written out (ToXml...), the unknown Attributes and Elements will be omit as these are not stored within the data binding objects.


PriceEnquirySampleLib::CQuoteRequestPtr spElm = PriceEnquirySampleLib::CQuoteRequest::CreateInstance();

LtXmlLib16::CXmlSerializationContext& ctx = LtXmlLib16::CXmlSerializationContext::GetDefaultContext();


elm->FromXmlFile(lpctFilename, ctx);

PriceEnquirySampleLib.QuoteRequest elm = new PriceEnquirySampleLib.QuoteRequest();

LiquidTechnologies.Runtime.Net40.XmlSerializationContext ctx = LiquidTechnologies.Runtime.Net40.XmlSerializationContext.Default;

ctx.IgnoreUnknownAttributes = true;
ctx.IgnoreUnknownElements = true;

elm.FromXmlFile(filename, ctx);


PriceEnquirySampleLib.QuoteRequest elm = new PriceEnquirySampleLib.QuoteRequest();
XmlSerializationContext ctx = XmlSerializationContext.Default;


elm.fromXmlFile(filename, ctx);

  Visual Basic

Dim oElm As PriceEnquiryLib.QuoteRequest
Dim ctx As LtXmlComLib16.XmlSerializationContext

Set oElm = New PriceEnquiryLib.QuoteRequest
Set ctx = LtXmlComLib16.DefaultXmlSerializationContext

ctx.IgnoreUnknownAttributes = True
ctx.IgnoreUnknownElements = True

oElm.FromXmlFile filename, ctx



Description Value
Article Created 28/6/2006
Versions Liquid XML 2005 (5.0.0) and greater
Also See C++ API, C# API, Java API, VB6 API, Controlling the exported XML