-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse children of a node as generic Element
#237
Comments
Issue solved. @Serializable
class Base {
var extensions: Extensions? = null
@Serializable
class Extensions {
var extension: List<Extension>? = null
@Serializable
@XmlIgnoreWhitespace
class Extension {
var type: String? = null
@XmlValue
val value: List<Element> = emptyList()
}
}
} Please, accept my apologies for the noise. Hopefully it will help someone else in their journey. |
Solved this issue too fast... It does compile and give me access to the first child. But going I lose the structure for the children, and their attributes. |
@TristanCaronUnity What do you mean you loose the structure? It should give you a list of the outermost elements ( |
The first element is correct, the tag name is preserved; I can do something like
Maybe it is expected behaviour. P.S.: I unblocked my self and did something like this @Serializable
class Extension(@XmlPolyChildren([".AdVerifications"]) val value: List<@Polymorphic Any>, val type: String? = null) {
companion object {
fun module(): SerializersModule {
return SerializersModule {
polymorphic(Any::class, AdVerifications::class, AdVerifications.serializer())
}
}
}
} |
I've added a test to the current dev version. It works correctly there. You want to note though that it the parsing includes whitespace text. The |
Hello,
Consider the following:
Is it possible to have the children to be set in the
List<Element>
property?Currently, I get an error saying:
The text was updated successfully, but these errors were encountered: