Scala - replace xml element with specific text <p>so i have this XMl</p> <pre><code>&lt;a&gt;blah&lt;/a&gt; </code></pre> <p>And i want to change it to </p> <pre><code>&lt;a&gt;someValueIDoNotKnowAtCompileTime&lt;/a&gt; </code></pre> <p>Currently, I am looking at <a href="http://stackoverflow.com/q/970675/1061426">this SO question</a> . However, this just changes the value to "2"</p> <p>What i want is exactly the same thing, but to be able to define the value (so that it can change at runtime - i am reading the values from a file!)</p> <p>I tried passing the value into the overridden methods, but that didn't work - compile errors everywhere (obviously)</p> <p>How can i change static xml with dynamic values?</p> <p><strong>ADDING CODE</strong></p> <pre><code>var splitString = someString.split("/t") //where someString is a line from a file val action = splitString(0) val ref = splitString(1) xmlMap.get(action) match { //maps the "action" string to some XML case Some(entry) =&gt; { val xmlToSend = insertRefIntoXml(ref,entry) //for the different XML, i want to put the string "ref" in an appropriate place } ... </code></pre>