Problem
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(); LtXmlLib21::CSerializationContext& ctx = LtXmlLib21::CSerializationContext::GetDefaultContext(); ctx.SetIgnoreUnknownAttributes(true); elm->FromXmlFile(lpctFilename, ctx); |
![]() ![]() |
---|
PriceEnquirySampleLib.QuoteRequest elm = new PriceEnquirySampleLib.QuoteRequest();
LiquidTechnologies.Runtime.Net40.SerializationContext ctx = LiquidTechnologies.Runtime.Net40.SerializationContext.Default; ctx.IgnoreUnknownAttributes = true; elm.FromXmlFile(filename, ctx); |
![]() ![]() |
---|
PriceEnquirySampleLib.QuoteRequest elm = new PriceEnquirySampleLib.QuoteRequest(); ctx.setIgnoreUnknownAttributes(true); elm.fromXmlFile(filename, ctx); |
![]() ![]() |
---|
Dim oElm As PriceEnquiryLib.QuoteRequest Set oElm = New PriceEnquiryLib.QuoteRequest ctx.IgnoreUnknownAttributes = True oElm.FromXmlFile filename, ctx |
Notes
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 |