scala String to scala.xml.Elem

Govind Singh picture Govind Singh · Aug 6, 2014 · Viewed 21.2k times · Source

I have to convert a string into XML

scala> val string="<play><scala></scala></play>"
string: String = <play><scala></scala></play>

scala> val xml=(<play><scala></scala></play>)
xml: scala.xml.Elem = <play><scala></scala></play>

Answer

Marth picture Marth · Aug 6, 2014
scala> scala.xml.XML.loadString(string)
res0: scala.xml.Elem = <play><scala/></play>