There is an existing xml file & xsd. as i want to write new data into the existing xml file without affecting any old data?
file.xml
<project>
<session>
<id>1234</id>
<name>abcd</name>
</session>
</project>
Now i want new entry id= 5678 & name = wxyz and my expected result should be,
<project>
<session>
<id>1234</id>
<name>abcd</name>
</session>
<session> // New Entry
<id>5678</id>
<name>wxyz</name>
</session>
</project>
How am i trying to do :
1. unmarshal the xml file to java object and save into ArrayList
2. get the new value and add into ArrayList
3. Marshal the object to existing XML file.
using DOM it’s very easy to do but i want to use jaxb, is there any simple tutorial or do you have any idea please?
Using JAXB here is very simple. Take a look here: http://www.vogella.de/articles/JAXB/article.html
It is not very detailed tutorial but I believe it is a good start and enough to implement your task.
Then take this one: http://jaxb.java.net/tutorial/