<p>If you have something like:</p>

<pre><code>val myStuff = Array(Person("joe",40), Person("mary", 35))
</code></pre>

<p>How do you create an XML value with that data as nodes? I know how to use { braces } in an XML expression to put a value, but this is a collection of values. Do I need to iterate explicitly or is there something better?</p>

<pre><code>val myXml = &lt;people&gt;{ /* what here?! */ }&lt;/people&gt;
</code></pre>

<p>The resulting value should be something like:</p>

<pre><code>&lt;people&gt;&lt;person&gt;&lt;name&gt;joe&lt;/name&gt;&lt;age&gt;40&lt;/age&gt;&lt;/person&gt;
&lt;person&gt;&lt;name&gt;mary&lt;/name&gt;&lt;age&gt;39&lt;/age&gt;&lt;/person&gt;&lt;/people&gt;
</code></pre>

As it's a functional programming language Array.map is probably what you're looking for:
```
```
class Person(name : String, age : Int){
    def toXml() = <person><name>{ name }</name><age>{ age }</age></person>
}

object xml {
    val people = List(
        new Person("Alice", 16),
        new Person("Bob", 64)
    )

    val data = <people>{ people.map(p => p.toXml()) }</people>

    def main(args : Array[String]){
        println(data)
    }
}
```
```
Results in:
```
```
<people><person><name>Alice</name><age>16</age></person><person><name>Bob</name><age>64</age></person></people>
```
```
A formatted result (for a better read):
```
```
<people>
   <person>
      <name>Alice</name>
      <age>16</age>
   </person>
   <person>
      <name>Bob</name>
      <age>64</age>
   </person>
</people>
```
```