Liquid XML Data Binder 2020
Removing Optional Attribute Default values from the exported XML.
Liquid XML Data Binder (C++, Java, VB6) > Using the Code > Changing the exported XML > Removing Optional Attribute Default values from the exported XML.

Removing Optional Attribute Default values from the exported XML.


By default the liquid XML libraries insert default values into missing optional attributes into the XML that they export.
This is not always the required functionality, and omitting these values still provides a valid XML document.


These values can be omitted from the Output XML, by setting the NoOptionalAttributeDefaultOutput Propery of the SerializationContext.

Sample Code


LtXmlLib18::CSerializationContext ctx = LtXmlLib18::CSerializationContext::GetDefaultContext();
std::tstring strXml = elm->ToXml(true, true, EOLType_LF, ctx);


LiquidTechnologies.Runtime.Net40.SerializationContext ctx = LiquidTechnologies.Runtime.Net40.SerializationContext.Default;
ctx.NoOptionalAttributeDefaultOutput = true;
string strXml = elm.ToXml(true, System.Xml.Formatting.Indented, LiquidTechnologies.Runtime.Net40.EOLType.CRLF, ctx);


com.liquid_technologies.ltxmllib18.SerializationContext ctx = com.liquid_technologies.ltxmllib18.SerializationContext.Default;
String strXml = elm.toXml(true, Formatting.Indented, Encoding.UTF8, EOLType.CRLF, ctx);

  Visual Basic

Dim ctx As XmlSerializationContext
Dim strXml As String
Set ctx = LtXmlComLib18.DefaultXmlSerializationContext
ctx.NoOptionalAttributeDefaultOutput = True
strXml = oElm.ToXml(True, XmlFormatting_Indented, EOLType_LF, ctx)



Description Value
Article Created 15/6/2006
Relates to Versions Liquid XML 2006 and greater