Why use XML to Kotlin instead of JSON to Kotlin?
Choose XML to Kotlin when the source payload is XML and the generated classes need to reflect nested elements, repeated nodes, and document-style structure rather than JSON objects and arrays.
Generate Kotlin data classes from XML samples when your Android or JVM app still receives XML responses and needs explicit transport models.
<user>
<id>101</id>
<name>Ada Lovelace</name>
<active>true</active>
<roles>
<role>admin</role>
<role>editor</role>
</roles>
<profile>
<email>ada@example.com</email>
<score>9.8</score>
</profile>
</user>
data class UserModel(
@JsonProperty("id") val id: Int,
@JsonProperty("name") val name: String,
@JsonProperty("active") val active: Boolean
)
Choose XML to Kotlin when the source payload is XML and the generated classes need to reflect nested elements, repeated nodes, and document-style structure rather than JSON objects and arrays.
Yes. Repeated XML nodes are inferred into collection fields, and nested elements become child Kotlin data classes based on the parsed XML sample.