java - add content to a created xml document -


here code:

import java.io.filewriter;  import java.io.ioexception;  import org.jdom2.attribute;  import org.jdom2.document;  import org.jdom2.element;  import org.jdom2.output.format;  import org.jdom2.output.xmloutputter;  try {     element fichadas = new element("fichadas");     document doc = new document(fichadas);     doc.setrootelement(fichadas);     element fichada = new element("fichada");     fichada.addcontent(new element("n_terminal").settext("xx"));     fichada.addcontent(new element("tarjeta").settext("xx"));     fichada.addcontent(new element("fecha").settext("xx"));     fichada.addcontent(new element("hora").settext("xx"));     fichada.addcontent(new element("causa").settext("xx"));     doc.getrootelement().addcontent(fichada);     xmloutputter xmloutput = new xmloutputter();     xmloutput.setformat(format.getprettyformat());     xmloutput.output(doc, new filewriter("c:\file.xml")); } catch(ioexception e) {  } 

i need add content existing xml document, not create document every time opened program


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -