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 day="Thu" date="10 Nov 2011" low="37" high="58" text="Partly Cloudy" code="29"/>
            <forecast day="Fri" date="11 Nov 2011" low="39" high="58" text="Mostly Cloudy" code="28"/>
            <forecast day="Sat" date="12 Nov 2011" low="32" high="49" text="Cloudy" 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())
原文链接:https://www.f2er.com/xml/296389.html

猜你在找的XML相关文章