I would like the Scala function to return a String &when setting input &, similarly for all other XML escaped characters.
I tried to use xml.Unparsed, possibly incorrectly, this does not give me the desired result:
scala> val amp = '&'
amp: Char = &
scala> <a>{amp}</a>.toString
res0: String = <a>&</a>
scala> import scala.xml._
import scala.xml._
scala> <a>{amp}</a>.child(0)
res1: scala.xml.Node = &
scala> xml.Unparsed(<a>{amp}</a>.child(0).toString)
res2: scala.xml.Unparsed = &
I also tried using xml.Utility.unescape, but it does not give any output at all:
scala> val sb = new StringBuilder
sb: StringBuilder =
scala> xml.Utility.unescape("&", sb)
res0: StringBuilder = null
scala> sb.toString
res1: String = ""
scala>
user972946
source
share