I'm looking to create a document like this:
<root/>
That I can add children to programatically. Theoretically, it would look like this:
val root_node_name = "root"
val doc = <{root_node_name}/>
But that doesn't seem to work:
error: not found: value <
So, what I tried instead was this:
val root_node_name = "root"
val doc = new scala.xml.Elem(null, root_node_name, null, scala.xml.TopScope, null)
That compiles but at runtime I get this null pointer exception:
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...
I'm using Scala 2.8. Any examples of how to pull this off? Thanks.