This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hello everyone. Does anybody know of an API to format XML strings?
I have lots of data in xml to debug, and having them all in a single line makes things very hard to understand. It would be great if I could just wirte something like: String formattedXml = XMLFormatter.format( xmlString ) ;
I'm starting my search, but I've found only thing for the .NET platform.
See HowToPrettyPrintXmlWithJava for doing the job with Xerces' XMLSerializer (requires Xerces), or DocumentToString for doing it with an "identity transform" (uglier formatting, but doesn't require third party libraries if you're using J2SE 1.4).