Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala method to pretty print XML directly to a java.io.Writer (not a string)?

Tags:

xml

scala

The scala.xml.XML.write method supports outputting an XML node sequence to a java.io.Writer, for example in a servlet response. However, it doesn't seem to have an option to output the XML in pretty printed format. Is there any Scala standard library function to pretty print an XML node sequence to a java.io.Writer?

Note: scala.xml.PrettyPrinter does not seem to be the answer because it only returns a string. The pretty printer would need to output directly to a java.io.Writer.

like image 613
Markus Miller Avatar asked Nov 29 '10 12:11

Markus Miller


1 Answers

I wrote a PrettyPrinter that can directly write to a given file: XMLPrettyPrinter

I use it in production.

like image 177
juanmirocks Avatar answered Oct 19 '22 17:10

juanmirocks