title: Scala - modifying nested elements in xml
body: <p>I'm learning scala, and I'm looking to update a nested node in some xml. I've got something working but i'm wondering if its the most elegant way.</p>
  
  <p>I have some xml: </p>
  
  <pre><code>val InputXml : Node =
  &lt;root&gt;
      &lt;subnode&gt;
          &lt;version&gt;1&lt;/version&gt;
      &lt;/subnode&gt;
      &lt;contents&gt;
          &lt;version&gt;1&lt;/version&gt;
      &lt;/contents&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And i want to update the <em>version</em> node in <em>subnode</em>, but not the one in <em>contents</em>.</p>
  
  <p>Here is my function: </p>
  
  <pre><code>def updateVersion( node : Node ) : Node = 
   {
     def updateElements( seq : Seq[Node]) : Seq[Node] = 
     {
          var subElements = for( subNode &lt;- seq ) yield
          {
              updateVersion( subNode )
          }   
          subElements
     }
  
     node match
     {
       case &lt;root&gt;{ ch @ _* }&lt;/root&gt; =&gt;
       {
          &lt;root&gt;{ updateElements( ch ) }&lt;/root&gt;
       }
       case &lt;subnode&gt;{ ch @ _* }&lt;/subnode&gt; =&gt;
       {
           &lt;subnode&gt;{ updateElements( ch ) }&lt;/subnode&gt; 
       }
       case &lt;version&gt;{ contents }&lt;/version&gt; =&gt;
       {
          &lt;version&gt;2&lt;/version&gt;
       }
       case other @ _ =&gt; 
       {
           other
       }
     }
   }
  </code></pre>
  
  <p>Is there a more succint way of writing this function?</p>