目录
解析 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())