As the title says it, I have a huge xml file (GBs)
... ...
You can do this quite easily with an XMLEventReader and several XMLEventWriters from the javax.xml.stream package.
XMLEventReader
XMLEventWriter