Suppose i have a xml file which has several nodes & children. I am using jaxb (unmarshalling & marshalling) to update the xml file when requires but wanted to know what exactly happens when….. ??
<parent>
<node>abc</node>
</parent>
now i wanted to update this xml by adding <node>xyz</node>, so what i do
-
Unmaeshall this xml file to java Object and add this new node as java object.
-
Marshall the updated Object to XML file.
my Question is : what happens when we marshall the java object to xml file ?
option a) xml file remove everything and write afresh.
option b) xml file only updated by just adding the new line.
If you are strictly talking about
Fileobjects then the answer given by Bozho is correct. If you consider the DOM representation then JAXB offers both approaches:Unmarshaller/Marshaller
In the following code originalDOM != marshalledDOM.
Binder
When using a
Bindera link is maintained between the objects and the DOM nodes they were unmarshalled from. If you modify the unmarshalled object theBinderalows you to apply those changes back to the original DOM. This approach is very useful when there is unmapped content in the document that you need to keep (such as comments and processing instructions).For More Information