I am trying to generate some XML on the fly in Scala.
I want to use a numeric character reference inside XML and write the resulting XML to the output stream.
Example:
val myXml = <body>Hello World</body> val writer = new java.io.FileWriter("test") scala.xml.XML.write(writer, myXml, "utf-8", false, null)
8198 is unicode for a tiny space character.
After executing the above fragment, the contents of the file "test"
<body>Hello World</body>
Instead, I expect
<body>Hello World</body>
Edit : Learned how to avoid XML in SO
source share