I have the following xml-node:
val xml = <fields><field name="one"></field><field name="two"></field></fields>
Now I would like to create a Map[String, Node] with the field-name as key.
for{x <- xml \ "field"} yield Map(x \ "@name" -> x)
Using yield above I get a List of Maps though:
List(Map((one,<field name="one"></field>)), Map((two,<field name="two"></field>)))
How do I functionally get a Map[String, Node] without going the imperative way (temp-vars) to transform the Maps in the List to the final desired Map, maybe without yield?
1 Answer