pdvrieze / xmlutil

XML Serialization library for Kotlin
https://pdvrieze.github.io/xmlutil/
Apache License 2.0
363 stars 30 forks source link

How to read a DOM Document from XML? #163

Closed StefanOltmann closed 1 year ago

StefanOltmann commented 1 year ago

I'm trying to replace the usage of org.xml.sax API.

The original code looks like this:

private fun parseInputSource(inputStream: java.io.InputStream): nl.adaptivity.xmlutil.dom.Document {

    return try {

        val inputSource = org.xml.sax.InputSource(inputStream)

        val factory = DocumentBuilderFactory.newInstance()

        val builder = factory.newDocumentBuilder()

        builder.setErrorHandler(null)

        builder.parse(inputSource)

    } catch (ex: org.xml.sax.SAXException) {
        throw ex
    }
}

How do I need to use xmlutil to get that DOM Document?