xmlutil icon indicating copy to clipboard operation
xmlutil copied to clipboard

Is it possible to output self-closing tags if empty?

Open martinbonnin opened this issue 4 months ago • 2 comments

By default, empty elements output both a start and end tag:

@Serializable
class Foo(
    @XmlElement
    val bar: String
)

xml.encodeToString(Foo(""))

Result:

<Foo><bar></bar></Foo>

Is it possible to output a self closing tag instead?

<Foo><bar/></Foo>

martinbonnin avatar Jun 22 '25 10:06 martinbonnin