The PrettyPrinter
XML formatter removes newlines from character data. How do I prevent this?
scala> import scala.xml._
import scala.xml._
scala> """line one
| line two"""
res0: java.lang.String =
line one
line two
scala> new PrettyPrinter(999, 3).format(Elem(null, "multiline", Null, TopScope, PCData(res0)))
res1: String = <multiline><![CDATA[line one line two]]></multiline>
Also see https://lampsvn.epfl.ch/trac/scala/ticket/4303.
You might try using ConstructingParser to escape your string, as detailed here:
http://blog.markfeeney.com/2011/03/scala-xml-gotchas.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With