commonMain.moe.tlaster.ktml.dom.Node.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktml-jvm Show documentation
Show all versions of ktml-jvm Show documentation
Html parser for Kotlin Multiplatform
package moe.tlaster.ktml.dom
sealed interface Node {
val name: String
}
data class Element(
override val name: String,
val namespace: String = "",
val parent: Element? = null,
) : Node {
val attributes = linkedMapOf()
val children = arrayListOf()
val innerText: String
get() = children.joinToString("") {
when (it) {
is Text -> it.text
is Element -> it.innerText
else -> ""
}
}
}
data class Text(
val text: String,
override val name: String = "#text",
) : Node {
override fun toString(): String {
return text
}
}
data class Comment(
val text: String,
override val name: String = "#comment",
) : Node {
override fun toString(): String {
return ""
}
}
data class Doctype(
override val name: String,
) : Node {
override fun toString(): String {
return ""
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy