main.phraseapp.parsers.xml.XmlParser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-client Show documentation
Show all versions of gradle-client Show documentation
JVM client to interact with Phrase via its API.
The newest version!
package phraseapp.parsers.xml
import org.w3c.dom.Document
import java.io.InputStream
import javax.xml.parsers.DocumentBuilderFactory
const val DEFAULT_IGNORE_COMMENTS = false
class XmlParser(stream: InputStream, ignoreComments: Boolean = DEFAULT_IGNORE_COMMENTS) {
constructor(xml: String, ignoreComments: Boolean = DEFAULT_IGNORE_COMMENTS) : this(xml.byteInputStream(), ignoreComments)
val document: Document
init {
val documentFactory = DocumentBuilderFactory.newInstance().apply {
isIgnoringComments = ignoreComments
}
document = documentFactory.newDocumentBuilder().parse(stream)
document.documentElement.normalize()
}
}