In scala, is there a simple way to get all elements of an XML doc represented as a list?
My code:
object HelloWorld {
def main(args: Array[String]) {
val res="76561193756669631"
val url=("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXYYYZZZ&steamids="+res+"&format=xml")
val str = scala.io.Source.fromURL(url.toString,"utf-8").mkString
val x=xml.XML.loadString(str)
var r=(x\\"steamid").mkString
r=r.replaceAll("""<[a-zA-Z0-9/]*?>""","")
println(r)
}}
retrieves the xml:
<response>
<players>
<player>
<steamid>76561193756669631</steamid>
<communityvisibilitystate>3</communityvisibilitystate>
<personaname>*******je01</personaname>
<lastlogoff>1320236285</lastlogoff>
<profileurl>
http://steamcommunity.com/profiles/76561193756669631/
</profileurl>
<avatar>
https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb.jpg
</avatar>
<avatarmedium>
https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_medium.jpg
</avatarmedium>
<avatarfull>
https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg
</avatarfull>
<personastate>0</personastate>
<primaryclanid>103582791429521408</primaryclanid>
<timecreated>1320224696</timecreated>
<personastateflags>0</personastateflags>
</player>
</players>
</response>
and outputs the steamid because I hardcoded it in. Is there a way to oputput a list of all the elements and their values?
My goal:
steamid: 76561193756669631
communityvisibilitystate: 3
personaname: *******je01
....