This problem occurs with 0.90.2 and 0.90.3. See the following example:
class Test {
@Serializable
@SerialName("element")
data class Element(
@XmlElement(true)
val a: String
)
@Serializable
@SerialName("element")
data class OtherElement(
@XmlElement(true)
val b: String
)
@Serializable
data class Parent(
val element: Element,
)
@Serializable
data class OtherParent(
val element: OtherElement,
)
@Serializable
data class Root(
val parent: Parent,
val otherParent: OtherParent,
)
@Test
fun `xml version 0_9_x test`() {
val xml = XML {
indent = 4
}
val root = Root(
parent = Parent(Element("element")),
otherParent = OtherParent(OtherElement("element")),
)
val serialized = xml.encodeToString(root)
println(serialized)
val deserialized: Root = XML.decodeFromString(serialized)
assertEquals(root, deserialized)
}
}
This will print the following XML:
<Root>
<Parent>
<element>
<a>element</a>
</element>
</Parent>
<OtherParent>
<element>
<a>element</a>
</element>
</OtherParent>
</Root>
Note how in OtherParent/element the tag is <a>, even though it should be <b>.
This problem occurs with 0.90.2 and 0.90.3. See the following example:
This will print the following XML:
Note how in
OtherParent/elementthe tag is<a>, even though it should be<b>.