redundent / kotlin-xml-builder

A lightweight type safe builder to build xml documents in Kotlin
Apache License 2.0
151 stars 17 forks source link

[Request] Support for rendering XML comments within generated XML #20

Closed ejektaflex closed 5 years ago

ejektaflex commented 5 years ago

Currently, I don't see a way of adding comments via the DSL, and it seems quite hard to do because nodes need a name, and comments are inherently unnamed (Unless you could their contained text). Adding support for comments in generated XML would be greatly appreciated!

ejektaflex commented 5 years ago

For reference, I am using this:

package util

import org.redundent.kotlin.xml.Node

class XmlComment(text: String): Node(text) {
    override fun render(builder: Appendable, indent: String, printOptions: PrintOptions) {
        builder.append("<!-- $nodeName -->")
    }
}

You can adapt this or do something similar if you'd like!

redundent commented 5 years ago

Thanks @ejektaflex This has been added in version 1.5.1 which is available now