Skip to content

Instantly share code, notes, and snippets.

@kkismd
Last active August 29, 2015 14:21
Show Gist options
  • Save kkismd/ef3fb20ecfa00f8983f3 to your computer and use it in GitHub Desktop.
Save kkismd/ef3fb20ecfa00f8983f3 to your computer and use it in GitHub Desktop.
val xml =
<body>
<item>
<name>aaaaa</name>
<url>httpppppp</url>
<description>cccc</description>
</item>
<item>
<name>aaaaa</name>
<url>httpppppp</url>
<description>cccc</description>
</item>
</body>
def fmt(url:String, name:String, desc:String): String = s"""<a href="$url">$name</a><p>$desc</p>"""
val names = xml \\ "name" map(_.text)
val urls = xml \\ "url" map(_.text)
val descriptions = xml \\ "description" map(_.text)
List(names, urls, descriptions).transpose.foreach(list =>
println(fmt(list(0),list(1),list(2)))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment