Jaxb: Printing Xml with proper formatting
Ever wondered when we print xml, instead of printing it in single line can’t we print with proper formatting and indentation. If you are using Jaxb then there is a nice little trick in to achieve that.
JAXBContext jc = JAXBContext.newInstance( "MyClass.class" ); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); marshaller.marshal( <object_to_marshal>, System.out );


July 6th, 2009 at 5:10 pm
works like a treat