Liquid XML Data Binder (C++, Java, VB6) / Using the Code / Changing the exported XML / Removing Optional Attribute Default values from the exported XML.
In This Topic
    Removing Optional Attribute Default values from the exported XML.
    In This Topic


    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


    LtXmlLib20::CSerializationContext ctx = LtXmlLib20::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.ltxmllib20.SerializationContext ctx = com.liquid_technologies.ltxmllib20.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 = LtXmlComLib20.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