Title
t

tess_snow

01/09/2018, 1:17 PM
looking for something like xmlslurper (groovy) for kotlin. Kotlin XML Binding (http://jonnyzzz.com/blog/2016/01/06/kotlin-xml/) seems useable. Opinions? Need to figure out how to parse an XML string into an object too using this lib..
k

kristofdho

01/09/2018, 1:28 PM
the git repo shows (sort of) how to parse them (https://github.com/jonnyzzz/kotlin.xml.bind), this one looks cleaner tho imo: https://github.com/kongsin/KotlinXMLParser
but if you can, you should use json instead
t

tess_snow

01/09/2018, 1:30 PM
Thanks. json sure, but not an option - rewrite of a legacy system very xml centric..
k

kristofdho

01/09/2018, 1:32 PM
as in xml setting files only used server side, or client provided xml files
because if it's all hidden it might be beneficial to switch to json, and maybe for now temporarily provide legacy xml support
t

tess_snow

01/09/2018, 1:45 PM
it’s GSRL7 xml files server side as specified by Dun & Bradstreet our partner. Nothing much to do about it 😉
Finally did it like this, there might be other ways..
val operationMetadata = JDOM.load(parseXml(messageText), OperationMetadata::class.java)

    private fun parseXml(messageText: String): Element {
        val saxBuilder = SAXBuilder()
        return saxBuilder.build(messageText.reader()).rootElement
    }
t

tess_snow

01/09/2018, 2:13 PM
thanks, will check it out 🙂