xmlutil icon indicating copy to clipboard operation
xmlutil copied to clipboard

Parse children of a node as generic `Element`

Open TristanCaronUnity opened this issue 1 year ago • 5 comments

Hello,

Consider the following:

<Extensions>
    <Extension type="AdVerifications">
        <AdVerifications>
            <Verification vendor="Something">
                <JavaScriptResource apiFramework="omid" browserOptional="true">
                    <![CDATA[https://google.com/video.js]]>
                </JavaScriptResource>
                <VerificationParameters>
                    <![CDATA[{"key":"21649"}]]>
                </VerificationParameters>
            </Verification>
        </AdVerifications>
    </Extension>
</Extensions>
@Serializable
class Base {
    var extensions: Extensions? = null

    @Serializable
    class Extensions {
        var extension: List<Extension>? = null

        @Serializable
        class Extension {
            var type: String? = null

            val value: List<Element> = emptyList()
        }
    }
}

Is it possible to have the children to be set in the List<Element> property?

Currently, I get an error saying:

UnknownXmlFieldException: Could not find a field for name (Base.Extensions.Extension) Extension/AdVerifications (Element)
  candidates: type (Attribute), value (Element) at position

TristanCaronUnity avatar Sep 08 '24 04:09 TristanCaronUnity