Using Sax As you want to modify XML this is not going to help you
Using DOM Since you care about memory(efficiency) this is not going to work
Using Stax This is what helps your concerns. You have also pointed on it. How to modify XML using Stax is discussed here