How to pretty print XML from Java?

I have an xml which is non-format as below. How i can make it nicely formatted xml.

Pass the books.xml in the below program , run the program and see output.

OutputNow we can see that books.xml is printed in nice format.


Posted in java programs and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">