In short; i have many empty lines generated in an XML file, and i am looking for a way to remove them as a way of leaning the file. How can i do that ? For detailed explanation; I currently have this XML file : And i use this Java code to delete all tags, and add new ones instead