Xoxo
A wrapper around org.w3c.dom with nicer Kotlin APIs ๐
Install / Use
/learn @martinbonnin/XoxoREADME
Xoxo ๐
Xoxo is a simple wrapper around org.w3c.dom to parse XML using nice Kotlin APIs. No more NodeList, .item(), etc... just use .children, .filterIsInstance<>() and all the Okio and Kotlin APIs we all love ๐.
Xoxo is designed for dynamic parsing in small JVM-only projects like Kotlin scripts and does not pretend to cover the full XML specification nor XML editing.
Installation
@file:DependsOn("net.mbonnin.xoxo:xoxo:0.4.0")
Read the text content of the first <div> tag in a HTML file
File("index.html").toXmlDocument()
.root
.childElements
.first { it.name == "body" }
.childElements
.first { it.name == "div" }
.textContent
Find all elements with a "videoId" attribute and display their duration
val xmlString = """
<root>
<items>
<item videoId="1" title="title1">
<duration>30:30</duration>
</item>
<item videoId="2" title="title2">
<duration>31:00</duration>
</item>
</items>
</root>
""".trimIndent()
xmlString.toXmlDocument()
.root
.walkElements()
.filter { it.attributes.containsKey("videoId") }
.forEach {
println(it.attributes["title"])
println("duration:" + it.childElements.single().textContent)
}
Related Skills
node-connect
352.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.9kQQBot ๅฏๅชไฝๆถๅ่ฝๅใไฝฟ็จ <qqmedia> ๆ ็ญพ๏ผ็ณป็ปๆ นๆฎๆไปถๆฉๅฑๅ่ชๅจ่ฏๅซ็ฑปๅ๏ผๅพ็/่ฏญ้ณ/่ง้ข/ๆไปถ๏ผใ
