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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.