As per your requirement, please check JAXB (
Java API for XML Binding) which exactly fits in.
In precise, JAXB as the term indicates, helps you to get the XML contents in terms of equivalent Java Objects and also to represent the Java objects back into XML representation.
When you have the Java object equivalence, you are free to do any changes to the content you want! Then you can convert back them into XML using the same JAXB.
The processes are called
Marshalling and
UnMarshalling.
This
tutorial is an excellent one which gives you enough information right from the basics.
You can also look into the
online documentation for the same.