PrettyPrinter
XML格式化程序从字符数据中删除换行符。我该如何防止这种情况?
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>
答案 0 :(得分:1)
您可以尝试使用ConstructingParser来转义字符串,详见此处: