how can i add data to an xml file and append to it ohter data if it exists ?
i tried the following but this code only creates one node of values and does not append to the file. it always removes the existing one and add the new one to it.
import java.beans.XMLEncoder;
import java.beans.XMLDecoder;
import java.io.*;
public class Main {
public static void main(String[] args) {
Question quest = new Question("Mouhib 9a7boun ?", "EYY");
try {
FileOutputStream fos = new FileOutputStream(new File("./quest.xml"));
XMLEncoder encoder = new XMLEncoder(fos);
encoder.writeObject(quest);
encoder.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
ArrayList<Question>if you need to add