Step into Kotlin - 22 - Xml

前端之家收集整理的这篇文章主要介绍了Step into Kotlin - 22 - Xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

目录

摘要

解析 xml

Xml

解析 XML

xml

<RSS>
    <channel>
        <title>Yahoo! Weather - Boulder,CO</title>
        <item>
            <title>Conditions for Boulder,CO at 2:54 pm MST</title>
            <forecast @H_502_61@day="Thu" @H_502_61@date="10 Nov 2011" @H_502_61@low="37" @H_502_61@high="58" @H_502_61@text="Partly Cloudy" @H_502_61@code="29"/>
            <forecast @H_502_61@day="Fri" @H_502_61@date="11 Nov 2011" @H_502_61@low="39" @H_502_61@high="58" @H_502_61@text="Mostly Cloudy" @H_502_61@code="28"/>
            <forecast @H_502_61@day="Sat" @H_502_61@date="12 Nov 2011" @H_502_61@low="32" @H_502_61@high="49" @H_502_61@text="Cloudy" @H_502_61@code="27"/>
        </item>
    </channel>
</RSS>

Kotlin

val f = File("coffeetime-kotlin/src/main/resources/weather.xml")

val builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
println(builder.parse(f).toXmlString())

猜你在找的XML相关文章