title: How do I create an XML root node in Scala without a literal element name?
body: <p>I'm looking to create a document like this:</p>
  
  <pre><code>&lt;root/&gt;
  </code></pre>
  
  <p>That I can add children to programatically. Theoretically, it would look like this:</p>
  
  <pre><code>val root_node_name = "root"
  val doc = &lt;{root_node_name}/&gt;
  </code></pre>
  
  <p>But that doesn't seem to work:</p>
  
  <pre><code>error: not found: value &lt;
  </code></pre>
  
  <p>So, what I tried instead was this:</p>
  
  <pre><code>val root_node_name = "root"
  val doc = new scala.xml.Elem(null, root_node_name, null, scala.xml.TopScope, null)  
  </code></pre>
  
  <p>That compiles but at runtime I get this null pointer exception:</p>
  
  <pre><code>java.lang.NullPointerException
  at scala.xml.Utility$.toXML(Utility.scala:201)
  at scala.xml.Utility$$anonfun$sequenceToXML$2.apply(Utility.scala:235)
  at scala.xml.Utility$$anonfun$sequenceToXML$2.apply(Utility.scala:235)
  at scala.Iterator$class.foreach(Iterator.scala:414)
  at scala.runtime.BoxedArray$AnyIterator.foreach(BoxedArray.scala:45)
  at scala.Iterable$class.foreach(Iterable...
  </code></pre>
  
  <p>I'm using Scala 2.8. Any examples of how to pull this off? Thanks.</p>