Liquid XML Objects (C#, Visual Basic .Net) / Using the Generated Code / XML Schema Handling / Mixed Content
In This Topic
    Mixed Content
    In This Topic
    Mixed content allows the XML contain text and elements to be interleaved together, a common example of this is xHtml.

    Mixed content is not a good fit when trying to bind XML Elements and attributes to properties within a generated class. The dynamic nature of mixed content means that the order of the contained elements and embedded text needs to be preserved.

    The end result is that compromises must be made when dealing with mixed content.

    The Liquid Xml Objects generator has the setting 'MixedContentHandling' which offers 2 options for dealing with mixed content.

    Ignore

    The mixed content flag is simply ignored on the xsd:element and xsd:complexType.

    Pros:

    • Child Elements are accessible via the LXO generated objects

    Cons:

    • Embedded text data will be discarded.
    • Data cannot be round-tripped, the text information will be discarded.

    TreatAsAny (Default)

    Each xsd:element and xsd:complexType that is marked as mixed is treated as an xs:any, this means that they will be treated as raw XML elements in the generated code, in C# they would be generated as the type System.Xml.Linq.XElement.

    Pros:

    • Provides full access to the data contained, including the order.
    • Data can be round-tripped (i.e. you get out what you read in).

    Cons:

    • Child elements are also treated as raw XML Elements, so you have to do additional work in order to load them into LXO generated classes.